chuck.js/app/Bootstrap/Socket.js
2012-07-28 13:38:31 +02:00

36 lines
790 B
JavaScript
Executable file

define([
'socket.io'
],
function (io) {
function Socket(server, options, coordinator) {
options.logLevel = typeof options.logLevel != 'undefined'
? options.logLevel
: 0;
this.coordinator = coordinator;
this.socket = io.listen(server);
this.init(options);
}
Socket.prototype.init = function (options){
var self = this;
this.socket.configure('development', function (){
this.set('log level', options.logLevel);
});
this.socket.on('connection', function (user){
self.onConnection(user);
});
}
Socket.prototype.onConnection = function (socketLink){
this.coordinator.createUser(socketLink);
}
return Socket;
});