Skip to content

Instantly share code, notes, and snippets.

View pauldenotter's full-sized avatar

Paul den Otter pauldenotter

  • Eindhoven, Netherlands
View GitHub Profile
@pauldenotter
pauldenotter / plugin.js
Created February 27, 2014 23:31
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'});