adding cls back in socketio index

v1.18.x
Aziz Khoury 9 years ago
parent 4f3a962f7f
commit 807e3a9d7e

@ -10,6 +10,7 @@ var winston = require('winston');
var db = require('../database');
var logger = require('../logger');
var ratelimit = require('../middleware/ratelimit');
var cls = require('../middleware/cls');
var Sockets = {};
var Namespaces = {};
@ -29,6 +30,7 @@ Sockets.init = function(server) {
io.use(authorize);
io.on('connection', onConnection);
io.on('disconnect', onDisconnect);
io.listen(server, {
transports: nconf.get('socket.io:transports')
@ -42,10 +44,14 @@ function onConnection(socket) {
logger.io_one(socket, socket.uid);
onConnect(socket);
cls.socket(socket, null, 'connection', function() {
onConnect(socket);
});
socket.on('*', function(payload) {
onMessage(socket, payload);
cls.socket(socket, payload, null, function() {
onMessage(socket, payload);
});
});
}
@ -58,6 +64,10 @@ function onConnect(socket) {
}
}
function onDisconnect(socket) {
cls.socket(socket, null, 'disconnect', function() {});
}
function onMessage(socket, payload) {
if (!payload.data.length) {

Loading…
Cancel
Save