2020-01-08 19:24:24 +00:00
|
|
|
// TODO const someSocketLogic = require('./middleware/socketssockets/...');
|
2020-01-21 22:33:40 +00:00
|
|
|
const socketIO = require('socket.io');
|
|
|
|
const io = socketIO({ cookie: false });
|
2020-01-08 19:24:24 +00:00
|
|
|
|
2020-01-24 05:25:08 +00:00
|
|
|
const gameQueries = require('./data/queries/game');
|
|
|
|
|
2020-01-26 00:50:18 +00:00
|
|
|
io.on('connection', socket=> {
|
|
|
|
socket.emit('connected', {message: 'socket connected'});
|
|
|
|
socket.on('connect_room', data => {
|
2020-01-28 06:40:03 +00:00
|
|
|
console.log(data)
|
|
|
|
if (data.user && data.user.email) {
|
|
|
|
delete data.user.email;
|
|
|
|
}
|
|
|
|
const roomIo = io.of(data.room);
|
|
|
|
roomIo.on('connection', socket => {
|
|
|
|
socket.emit('connected')
|
|
|
|
socket.emit('new_user', data);
|
|
|
|
})
|
|
|
|
})
|
2020-01-26 00:50:18 +00:00
|
|
|
})
|
2020-01-08 19:24:24 +00:00
|
|
|
|
2020-01-26 00:50:18 +00:00
|
|
|
const roomSocket = (roomId) => {
|
2020-01-28 06:40:03 +00:00
|
|
|
|
2020-01-26 00:50:18 +00:00
|
|
|
const roomIo = io.of(roomId)
|
|
|
|
roomIo.on('connection', socket => {
|
2020-01-28 06:40:03 +00:00
|
|
|
console.log('connected room')
|
2020-01-26 00:50:18 +00:00
|
|
|
socket.on('connect_room', data => {
|
2020-01-28 06:40:03 +00:00
|
|
|
if (data.user && data.user.email) {
|
|
|
|
delete data.user.email;
|
|
|
|
}
|
|
|
|
socket.emit('new_user', data);
|
2020-01-24 23:51:15 +00:00
|
|
|
})
|
2020-01-26 00:50:18 +00:00
|
|
|
})
|
2020-01-28 06:40:03 +00:00
|
|
|
return roomIo;
|
2020-01-24 08:07:40 +00:00
|
|
|
}
|
|
|
|
|
2020-01-21 22:33:40 +00:00
|
|
|
module.exports = {
|
|
|
|
io,
|
2020-01-26 00:50:18 +00:00
|
|
|
roomSocket
|
2020-01-24 05:25:08 +00:00
|
|
|
}
|