diff --git a/src/socket.io/index.js b/src/socket.io/index.js index 08dab140e6..171a80d38f 100644 --- a/src/socket.io/index.js +++ b/src/socket.io/index.js @@ -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);