mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
keep track of the last 20 events
This commit is contained in:
@@ -124,11 +124,6 @@ function onMessage(socket, payload) {
|
|||||||
return winston.warn('[socket.io] Empty method name');
|
return winston.warn('[socket.io] Empty method name');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ratelimit.isFlooding(socket)) {
|
|
||||||
winston.warn('[socket.io] Too many emits! Disconnecting uid : ' + socket.uid + '. Message : ' + eventName);
|
|
||||||
return socket.disconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
var parts = eventName.toString().split('.'),
|
var parts = eventName.toString().split('.'),
|
||||||
namespace = parts[0],
|
namespace = parts[0],
|
||||||
methodToCall = parts.reduce(function(prev, cur) {
|
methodToCall = parts.reduce(function(prev, cur) {
|
||||||
@@ -146,6 +141,17 @@ function onMessage(socket, payload) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
socket.previousEvents = socket.previousEvents || [];
|
||||||
|
socket.previousEvents.push(eventName);
|
||||||
|
if (socket.previousEvents.length > 20) {
|
||||||
|
socket.previousEvents.shift();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ratelimit.isFlooding(socket)) {
|
||||||
|
winston.warn('[socket.io] Too many emits! Disconnecting uid : ' + socket.uid + '. Events : ' + socket.previousEvents);
|
||||||
|
return socket.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
if (Namespaces[namespace].before) {
|
if (Namespaces[namespace].before) {
|
||||||
Namespaces[namespace].before(socket, eventName, function() {
|
Namespaces[namespace].before(socket, eventName, function() {
|
||||||
callMethod(methodToCall, socket, params, callback);
|
callMethod(methodToCall, socket, params, callback);
|
||||||
|
|||||||
Reference in New Issue
Block a user