Created
February 27, 2014 23:31
-
-
Save pauldenotter/9261976 to your computer and use it in GitHub Desktop.
Binding socket.io to a hapi.js plugin in node.js
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 socketIO = require('socket.io'), | |
io; | |
// hapi plugin registration | |
exports.register = function(plugin, options, next) { | |
// this is the hapi specific binding | |
io = socketIO.listen(plugin.servers[0].listener); | |
io.sockets.on('connection', function(socket) { | |
socket.emit({msg: 'welcome'}); | |
}); | |
next(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment