// When the user connects.. perform this
function onConnect(socket) {
- // When the client emits 'info', this listens and executes
- socket.on('info', function (data) {
- console.info('[%s] %s', socket.address, JSON.stringify(data, null, 2));
- });
+ // When the client emits 'info', this listens and executes
+ socket.on('info', function (data) {
+ console.info('[%s] %s', socket.address, JSON.stringify(data, null, 2));
+ });
- // Insert sockets below
- require('../api/report/report.socket').register(socket);
+ // Insert sockets below
+ require('../api/report/report.socket').register(socket);
}
module.exports = function (socketio) {
- // socket.io (v1.x.x) is powered by debug.
- // In order to see all the debug output, set DEBUG (in server/config/local.env.js) to including the desired scope.
- //
- // ex: DEBUG: "http*,socket.io:socket"
-
- // We can authenticate socket.io users and access their token through socket.handshake.decoded_token
- //
- // 1. You will need to send the token in `client/components/socket/socket.service.js`
- //
- // 2. Require authentication here:
- // socketio.use(require('socketio-jwt').authorize({
- // secret: config.secrets.session,
- // handshake: true
- // }));
-
- socketio.on('connection', function (socket) {
- socket.connectedAt = new Date();
-
- // Call onDisconnect.
- socket.on('disconnect', function () {
- onDisconnect(socket);
- console.info('[%s] DISCONNECTED', socket.handshake.address);
+ // socket.io (v1.x.x) is powered by debug.
+ // In order to see all the debug output, set DEBUG (in server/config/local.env.js) to including the desired scope.
+ //
+ // ex: DEBUG: "http*,socket.io:socket"
+
+ // We can authenticate socket.io users and access their token through socket.handshake.decoded_token
+ //
+ // 1. You will need to send the token in `client/components/socket/socket.service.js`
+ //
+ // 2. Require authentication here:
+ // socketio.use(require('socketio-jwt').authorize({
+ // secret: config.secrets.session,
+ // handshake: true
+ // }));
+
+ socketio.on('connection', function (socket) {
+ socket.connectedAt = new Date();
+
+ // Call onDisconnect.
+ socket.on('disconnect', function () {
+ onDisconnect(socket);
+ console.info('[%s] DISCONNECTED', socket.handshake.address);
+ });
+
+ // Call onConnect.
+ onConnect(socket);
+ console.info('[%s] CONNECTED', socket.handshake.address);
});
-
- // Call onConnect.
- onConnect(socket);
- console.info('[%s] CONNECTED', socket.handshake.address);
- });
};