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",
|
"semver": "^5.0.1",
|
||||||
"serve-favicon": "^2.1.5",
|
"serve-favicon": "^2.1.5",
|
||||||
"sitemap": "^1.4.0",
|
"sitemap": "^1.4.0",
|
||||||
"socket.io": "^1.2.1",
|
"socket.io": "^1.4.0",
|
||||||
"socket.io-client": "^1.2.1",
|
"socket.io-client": "^1.4.0",
|
||||||
"socket.io-redis": "^0.2.0",
|
"socket.io-redis": "^1.0.0",
|
||||||
"socketio-wildcard": "~0.2.0",
|
"socketio-wildcard": "~0.3.0",
|
||||||
"string": "^3.0.0",
|
"string": "^3.0.0",
|
||||||
"templates.js": "0.3.1",
|
"templates.js": "0.3.1",
|
||||||
"toobusy-js": "^0.4.2",
|
"toobusy-js": "^0.4.2",
|
||||||
|
|||||||
@@ -6,10 +6,9 @@
|
|||||||
|
|
||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
express = require('express'),
|
|
||||||
winston = require('winston'),
|
winston = require('winston'),
|
||||||
util = require('util'),
|
util = require('util'),
|
||||||
socketio = require('socket.io'),
|
|
||||||
file = require('./file'),
|
file = require('./file'),
|
||||||
meta = require('./meta'),
|
meta = require('./meta'),
|
||||||
morgan = require('morgan');
|
morgan = require('morgan');
|
||||||
@@ -160,16 +159,22 @@ var opts = {
|
|||||||
/*
|
/*
|
||||||
* Restore all hijacked sockets to their original emit/on functions
|
* Restore all hijacked sockets to their original emit/on functions
|
||||||
*/
|
*/
|
||||||
var clients = []; //socket.io.sockets.clients(); doesn't work in socket.io 1.x
|
if (!socket || !socket.io || !socket.io.sockets || !socket.io.sockets.sockets) {
|
||||||
clients.forEach(function(client) {
|
return;
|
||||||
if(client.oEmit && client.oEmit !== client.emit) {
|
}
|
||||||
client.emit = client.oEmit;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
if(client.$oEmit && client.$oEmit !== client.$emit) {
|
if(client.$oEmit && client.$oEmit !== client.$emit) {
|
||||||
client.$emit = client.$oEmit;
|
client.$emit = client.$oEmit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger.io = function(socket) {
|
Logger.io = function(socket) {
|
||||||
@@ -177,15 +182,16 @@ var opts = {
|
|||||||
* Go through all of the currently established sockets & hook their .emit/.on
|
* 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var clients = socket.io.sockets.sockets;
|
var clients = socket.io.sockets.sockets;
|
||||||
|
for(var sid in clients) {
|
||||||
clients.forEach(function(client) {
|
if (clients.hasOwnProperty(sid)) {
|
||||||
Logger.io_one(client, client.uid);
|
Logger.io_one(clients[sid], clients[sid].uid);
|
||||||
});
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Logger.io_one = function(socket, uid) {
|
Logger.io_one = function(socket, uid) {
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ Sockets.getSocketCount = function() {
|
|||||||
if (!io) {
|
if (!io) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return io.sockets.sockets.length;
|
return Object.keys(io.sockets.sockets).length;
|
||||||
};
|
};
|
||||||
|
|
||||||
Sockets.getUserSocketCount = function(uid) {
|
Sockets.getUserSocketCount = function(uid) {
|
||||||
|
|||||||
Reference in New Issue
Block a user