more crash fixes to socketS

v1.18.x
Baris Soner Usakli 11 years ago
parent ba8e98520c
commit 6da6baa213

@ -140,8 +140,11 @@ Sockets.init = function() {
}); });
} }
if(!payload.name) {
return winston.warn('[socket.io] Empty method name');
}
var parts = payload.name.split('.'), var parts = payload.name.toString().split('.'),
namespace = parts.slice(0, 1), namespace = parts.slice(0, 1),
methodToCall = parts.reduce(function(prev, cur) { methodToCall = parts.reduce(function(prev, cur) {
if (prev !== null && prev[cur]) { if (prev !== null && prev[cur]) {
@ -151,17 +154,16 @@ Sockets.init = function() {
} }
}, Namespaces); }, Namespaces);
if (methodToCall !== null) { if(!methodToCall) {
return winston.warn('[socket.io] Unrecognized message: ' + payload.name);
}
if (Namespaces[namespace].before) { if (Namespaces[namespace].before) {
Namespaces[namespace].before(socket, function() { Namespaces[namespace].before(socket, function() {
callMethod(methodToCall);
});
} else {
callMethod(methodToCall); callMethod(methodToCall);
} });
} else { } else {
winston.warn('[socket.io] Unrecognized message: ' + payload.name); callMethod(methodToCall);
} }
}); });
}); });

Loading…
Cancel
Save