Skip to content

Instantly share code, notes, and snippets.

@pauldenotter
Created February 27, 2014 23:31
Show Gist options
  • Save pauldenotter/9261976 to your computer and use it in GitHub Desktop.
Save pauldenotter/9261976 to your computer and use it in GitHub Desktop.
Binding socket.io to a hapi.js plugin in node.js
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