-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsocketController.js
More file actions
27 lines (25 loc) · 972 Bytes
/
socketController.js
File metadata and controls
27 lines (25 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var logHelper = require('./logHelper'),
lh = new logHelper(),
socketHandlers = require('./socketHandlers');
function SocketController() {
// var _father = new socketHandlers();
socketHandlers.call(this); // add socketHandlers properties to SocketController
this.version = '0.1';
var _father = this; // private property _father refers to this SocketController, this property pass to the return object
return {
init: function(io, users) {
_father.init(io, users);
return this;
},
route: function() {
_father.io.on('connection', function(socket) { // listen on connection event for incoming sockets
socket.haslogin = false;
var handlers = _father.socketHandlers;
for (var i in handlers) {
socket.on(i, handlers[i]);
};
});
}
};
};
module.exports = SocketController;