Getting started
Installation
$ npm i @marblejs/websocketsor if you are a hipster:
$ yarn add @marblejs/websocketsBootstrapping
Like httpListener the WebSocket module defines a similar way of bootstrapping the app. The webSocketListener includes definitions of all middlewares and WebSocket effects.
const effects = [
effect1$,
effect2$,
// ...
];
const middlewares = [
middleware1$,
middleware2$,
// ...
];
export default webSocketListener({ effects, middlewares });To connect the previously configured WebSocket listener, you have to create a context token first.
Then all you have to do is to register the defined module inside createServer dependencies.
You can create and run a WebSocket server by providing the port value in webSocketListener config object. You can also upgrade the currently running http server by providing noServer: true in config object or by ommiting it.
Last updated