Leverage!
WebSockets forThis plugin supports the websocket
component and middleware types.
Config
event: 'event-name' namespace: '/my-namespace' // optional
Example
{ super thisconfig = type: 'websocket' websocket: /* * Specify an event */ event: 'ping' /* * Optionally specify a namespace */ namespace: '/my-namespace' } /* * Then the callback for our type. This is supplied with * the `data` and `socket` for this request, and the * global `io` instance. */ { socket }
Then just make sure to add the plugin to Leverage's manager along with your component instance!
Here, we'll also use the http
middleware to start the server listening.
/* ... all the code from the previous example ... */ managermanager manager /* * Don't forget to listen on a port! */http