Hapi-socket.io
Implementacion de socket.io para hapijs .
Requirements
- Hapi js v17 +
Installation
$ npm install hapi-socket.io --save
Usage
const hapiSocketIo = async { await server ...}
Using hapi-socket.io
server} //handler function respond to the same customermoduleexports{ var socket = contextsocket const result = await contextserverseneca; socket return hcontinue;} //handler function to emit to all customermoduleexports{ var io = contextio const result = await contextserverseneca; iosockets return hcontinue;} //handler function to emit to others customermoduleexports{ var socket = contextsocket const result = await contextserverseneca; socketbroadcast return hcontinue;} //The context variable contains... io: io socket: socket event: event data: data server: ser
Client Example
var io = ;var ioClient = io;console;ioClient;ioClient;ioClient;
hapi-socket.io options
auth: text string with the defined security strategy, false, in case of not requiring authentication socketoptions: you can define the options of the socket io library
Auth options
We have added, the option to validate with the authentication strategy defined in the server, This option is valid only with the socket configuration that allows the sending of extraHeaders.
// Client examplethissocket = io;
please do the registry after define your auth strategy
//Auth API with JWTserverauth; serverauth; await server;
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License