keep track of the last 20 events

v1.18.x
barisusakli 10 years ago
parent c4bc51b834
commit aab2bc0b39

@ -124,11 +124,6 @@ function onMessage(socket, payload) {
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('.'),
namespace = parts[0],
methodToCall = parts.reduce(function(prev, cur) {
@ -146,6 +141,17 @@ function onMessage(socket, payload) {
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) {
Namespaces[namespace].before(socket, eventName, function() {
callMethod(methodToCall, socket, params, callback);

Loading…
Cancel
Save