hapio
v2.0.0
Published
A simple bridge plugin between hapi and socket.io
Downloads
108
Maintainers
Readme
hapio
A simple bridge plugin between HapiJS and SocketIO.
Plugin registration
const server = new Hapi.Server({
port: 3000,
host: 'localhost',
});
async function start() {
try {
await server.register(hapio, {
serverOptions: {
// socket.io options
}
});
await server.start();
} catch (e) {
console.error(e);
}
}
start();
Using hapio
const io = server.plugins.hapio.io;
io.on('connection', function(socket) {
console.log(`${socket.id} connected !`);
socket.on('test', function(e) {
console.log('Test received !');
});
});
hapio options
serverOptions
: (Not required/Defaults to an empty object) Options to pass to socket.io's constructor.
A great idea?
Do not hesitate to make a pull request
An issue with hapio?
Just open an issue on Github and I will fix it as soon as possible