mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-10 15:21:56 +00:00
Only show unique gatherers
This commit is contained in:
parent
fb2ca2a4f3
commit
acf3c226b3
1 changed files with 18 additions and 3 deletions
|
@ -6,6 +6,8 @@ var enslClient = require(path.join(__dirname, "../lib/ensl/client"))();
|
||||||
var chatController = require(path.join(__dirname, "../lib/chat/controller"));
|
var chatController = require(path.join(__dirname, "../lib/chat/controller"));
|
||||||
var winston = require("winston");
|
var winston = require("winston");
|
||||||
|
|
||||||
|
var gathererCache = {};
|
||||||
|
|
||||||
module.exports = function (io) {
|
module.exports = function (io) {
|
||||||
var root = io.of("/");
|
var root = io.of("/");
|
||||||
var authorised = io.of("/authorised");
|
var authorised = io.of("/authorised");
|
||||||
|
@ -31,11 +33,24 @@ module.exports = function (io) {
|
||||||
var refreshGatherers = function (socket) {
|
var refreshGatherers = function (socket) {
|
||||||
var receiver = (socket !== undefined) ? socket : root;
|
var receiver = (socket !== undefined) ? socket : root;
|
||||||
|
|
||||||
|
var newCache = {};
|
||||||
|
root.sockets.forEach(function (socket) {
|
||||||
|
var user = socket._user;
|
||||||
|
newCache[user.id] = user;
|
||||||
|
});
|
||||||
|
gathererCache = newCache;
|
||||||
|
|
||||||
|
var gatherers = [];
|
||||||
|
|
||||||
|
for (var id in gathererCache) {
|
||||||
|
if (gathererCache.hasOwnProperty(id)) {
|
||||||
|
gatherers.push(gathererCache[id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
receiver.emit('gatherCount', {
|
receiver.emit('gatherCount', {
|
||||||
count: root.sockets.length,
|
count: root.sockets.length,
|
||||||
gatherers: root.sockets.map(function (socket) {
|
gatherers: gatherers
|
||||||
return socket._user
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue