Bootstrapping
Setting up a socket server
Initialize socket server
Setting up the socket server done by the socketService.init
method:
By existing server
By port
Example
For ServerModule (@sugoi/server)
Server module provide the ability to initiate services on the module initialization. Since socketServer is depended on the initialized http server instance we can delay it creation by using factory, this will be done by intercept the init method with an arrow function.
Example
Init parameters
serverInstance
= The server instance the socket server should be attached to.
socketConfig?:socketOptions
- The socket server configurations with the same interface as on socket.io documentation
namespace:string
- The socket server namespace to bind to, allow to assign different endpoint to the socket server, more info on socket.io documentation.
Returned value
The returned value of the SocketHandler.init
method is the socket server instance (SocketIOStatic.Server
).
Last updated