mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-29 07:32:14 +00:00
Fixing issues after upgrading socket.io version
This commit is contained in:
parent
cd648d6c6c
commit
01351c8d8b
1 changed files with 16 additions and 12 deletions
|
@ -23,14 +23,16 @@ var enslClient = require("../ensl/client")();
|
|||
var _ = require("lodash");
|
||||
|
||||
module.exports = namespace => {
|
||||
var refreshUsers = socket => {
|
||||
var receivers = (socket !== undefined) ? [socket] : namespace.sockets;
|
||||
|
||||
var newCache = {};
|
||||
namespace.sockets.forEach(socket => {
|
||||
var user = socket._user;
|
||||
var refreshUsers = socket => {
|
||||
var receivers = (socket !== undefined) ? [socket] : namespace.sockets;
|
||||
|
||||
var newCache = {};
|
||||
for(let socketid in namespace.sockets) {
|
||||
let socket = namespace.sockets[socketid];
|
||||
var user = socket._user;
|
||||
newCache[user.id] = user;
|
||||
});
|
||||
}
|
||||
|
||||
userCache = newCache;
|
||||
|
||||
var users = [];
|
||||
|
@ -41,18 +43,20 @@ module.exports = namespace => {
|
|||
}
|
||||
}
|
||||
|
||||
receivers.forEach(socket => {
|
||||
socket.emit('users:update', {
|
||||
|
||||
for(let socketid in receivers) {
|
||||
let socket = receivers[socketid];
|
||||
socket.emit('users:update', {
|
||||
count: users.length,
|
||||
users: users,
|
||||
currentUser: socket._user
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
namespace.on('connection', socket => {
|
||||
refreshUsers();
|
||||
|
||||
|
||||
socket.on('users:refresh', refreshUsers.bind(null, socket));
|
||||
|
||||
socket.on('users:update:profile', data => {
|
||||
|
|
Loading…
Reference in a new issue