Skip to content

Instantly share code, notes, and snippets.

@ralt
Forked from tbergeron/gist:2769370
Created May 22, 2012 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralt/2769373 to your computer and use it in GitHub Desktop.
Save ralt/2769373 to your computer and use it in GitHub Desktop.
module.exports = {
io: null,
socket: null,
createReactiveMethod: function() {},
initialize: function(server) {
console.log("initialized!");
this.io = require('socket.io').listen(server);
var that = this;
this.io.sockets.on('connection', function(socket) {
that.socket = socket;
that.createReactiveMethod = createReactiveMethod.bind( this );
});
}
}
function createReactiveMethod(name, callback) {
console.log("creating method " + name);
this.socket.on(name, callback);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment