Created
July 3, 2014 11:52
-
-
Save nulltask/f4ab8fd743e858bb65b8 to your computer and use it in GitHub Desktop.
Forward events to socket.io namespace.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Emitter = require('events').EventEmitter; | |
var emitter = new Emitter(); | |
var io = require('socket.io')(); | |
var fwd = require('forward-events'); | |
var nsp = io.of('/what-time-is-it'); | |
fwd(emitter, nsp); | |
setInterval(function() { | |
emitter.emit('now', new Date()); | |
}, 1000); | |
io.listen(3000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"forward-events": "0.0.1", | |
"socket.io": "^1.0.6" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment