mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 18:56:15 +01:00
closes #4032
This commit is contained in:
@@ -69,10 +69,10 @@
|
||||
"semver": "^5.0.1",
|
||||
"serve-favicon": "^2.1.5",
|
||||
"sitemap": "^1.4.0",
|
||||
"socket.io": "^1.2.1",
|
||||
"socket.io-client": "^1.2.1",
|
||||
"socket.io-redis": "^0.2.0",
|
||||
"socketio-wildcard": "~0.2.0",
|
||||
"socket.io": "^1.4.0",
|
||||
"socket.io-client": "^1.4.0",
|
||||
"socket.io-redis": "^1.0.0",
|
||||
"socketio-wildcard": "~0.3.0",
|
||||
"string": "^3.0.0",
|
||||
"templates.js": "0.3.1",
|
||||
"toobusy-js": "^0.4.2",
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
express = require('express'),
|
||||
winston = require('winston'),
|
||||
util = require('util'),
|
||||
socketio = require('socket.io'),
|
||||
|
||||
file = require('./file'),
|
||||
meta = require('./meta'),
|
||||
morgan = require('morgan');
|
||||
@@ -160,8 +159,13 @@ var opts = {
|
||||
/*
|
||||
* Restore all hijacked sockets to their original emit/on functions
|
||||
*/
|
||||
var clients = []; //socket.io.sockets.clients(); doesn't work in socket.io 1.x
|
||||
clients.forEach(function(client) {
|
||||
if (!socket || !socket.io || !socket.io.sockets || !socket.io.sockets.sockets) {
|
||||
return;
|
||||
}
|
||||
var clients = socket.io.sockets.sockets;
|
||||
for (var sid in clients) {
|
||||
if (clients.hasOwnProperty(sid)) {
|
||||
var client = clients[sid];
|
||||
if(client.oEmit && client.oEmit !== client.emit) {
|
||||
client.emit = client.oEmit;
|
||||
}
|
||||
@@ -169,7 +173,8 @@ var opts = {
|
||||
if(client.$oEmit && client.$oEmit !== client.$emit) {
|
||||
client.$emit = client.$oEmit;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Logger.io = function(socket) {
|
||||
@@ -177,15 +182,16 @@ var opts = {
|
||||
* Go through all of the currently established sockets & hook their .emit/.on
|
||||
*/
|
||||
|
||||
if (!socket || !socket.io || !socket.io.sockets || !Array.isArray(socket.io.sockets.sockets)) {
|
||||
if (!socket || !socket.io || !socket.io.sockets || !socket.io.sockets.sockets) {
|
||||
return;
|
||||
}
|
||||
|
||||
var clients = socket.io.sockets.sockets;
|
||||
|
||||
clients.forEach(function(client) {
|
||||
Logger.io_one(client, client.uid);
|
||||
});
|
||||
for(var sid in clients) {
|
||||
if (clients.hasOwnProperty(sid)) {
|
||||
Logger.io_one(clients[sid], clients[sid].uid);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Logger.io_one = function(socket, uid) {
|
||||
|
||||
@@ -199,7 +199,7 @@ Sockets.getSocketCount = function() {
|
||||
if (!io) {
|
||||
return 0;
|
||||
}
|
||||
return io.sockets.sockets.length;
|
||||
return Object.keys(io.sockets.sockets).length;
|
||||
};
|
||||
|
||||
Sockets.getUserSocketCount = function(uid) {
|
||||
|
||||
Reference in New Issue
Block a user