|
|
|
@ -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,11 +44,15 @@ function onConnection(socket) {
|
|
|
|
|
|
|
|
|
|
logger.io_one(socket, socket.uid);
|
|
|
|
|
|
|
|
|
|
cls.socket(socket, null, 'connection', function() {
|
|
|
|
|
onConnect(socket);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
socket.on('*', function(payload) {
|
|
|
|
|
cls.socket(socket, payload, null, function() {
|
|
|
|
|
onMessage(socket, payload);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onConnect(socket) {
|
|
|
|
@ -58,6 +64,10 @@ function onConnect(socket) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onDisconnect(socket) {
|
|
|
|
|
cls.socket(socket, null, 'disconnect', function() {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onMessage(socket, payload) {
|
|
|
|
|
if (!payload.data.length) {
|
|
|
|
|