Websockets
Returns WebsocketService singleton instance as a container of the Websockets implementations it will be used to extract and create the listeners to messages and setup on your way the responses for websockets. Singleton still not created then initialize it a new Singleton instance.
Constructor WebsocketService()#
Parameters
Name | Optional | Type | Defaults | Description | ||
---|---|---|---|---|---|---|
ws | Yes | Websocket.Server | Non Secure Websocket Server Instance. | |||
wss | Yes | Websocket.Server | Secure Websocket Server Instance. |
#
Properties privateStatic instance :Websocket.Server#
This is the initialized Singleton instance and will be undefined if not initialized.
private ws :Websocket.Server#
Private and readonly property that contains an instance of WebSocket.Server.
private wss :Websocket.Server#
Private and readonly property that contains an instance of WebSocket.Server over secure protocol.
public httpServer :http.Server#
Public property that contains an instance for http.Server;
public httpsServer :https.Server#
Public property that contains an instance for https.Server;
#
Methods publicStatic getInstance() ⇒WebsocketService#
Returns WebsocketService singleton instance, however, if Singleton still is not already initialize this will create the Singleton instance instead return it and for that ws should passed as minimum requirement to initialize this.
Parameters
Name | Optional | Type | Defaults | Description | ||
---|---|---|---|---|---|---|
ws | Yes | Websocket.Server | Non Secure Websocket Server Instance. | |||
wss | Yes | Websocket.Server | Secure Websocket Server Instance. |
publicStatic init() ⇒void#
Try to initialize WebsocketService singleton instance when is not already initialized this will create the Singleton instance and ws argument should be passed as minimum requirement to initialize this. If already initialized this will be ignored.
Parameters
Name | Optional | Type | Defaults | Description | ||
---|---|---|---|---|---|---|
ws | Yes | Websocket.Server | Non Secure Websocket Server Instance. | |||
wss | Yes | Websocket.Server | Secure Websocket Server Instance. |
publicStatic clear() ⇒void#
Clear the Singleton instance and ready to be created again.
public getWebsocket(httpServer:http.Server | https.Server) ⇒Websocket.Server#
Returns the mapped Websocket Server attached returns WebSocket.Server
Parameters
Name | Optional | Type | Defaults | Description | ||
---|---|---|---|---|---|---|
httpServer | No | http.Server | https.Server | Get Websocket instance associated with the http or https Server. |
public setHttpServer(httpServer:http.Server | https.Server) ⇒void#
This populate the properties httpServer or httpsServer depends on the type of server passed as arguments it will save it on the respective Singleton property.
Parameters
Name | Optional | Type | Defaults | Description | ||
---|---|---|---|---|---|---|
httpServer | No | http.Server | https.Server | Get Websocket instance associated with the http or https Server. |
public setWebsocket(ws:Websocket.Server) ⇒Websocket.Server#
This populate the properties httpServer or httpsServer depends on the type of server passed as arguments it will save it on the respective Singleton property.
Parameters
Name | Optional | Type | Defaults | Description | ||
---|---|---|---|---|---|---|
ws | No | Websocket.Server | Assign Websocket Server Instance. |
public setSecureWebsocket(wss:Websocket.Server) ⇒Websocket.Server#
This populate the properties httpServer or httpsServer depends on the type of server passed as arguments it will save it on the respective Singleton property.
Parameters
Name | Optional | Type | Defaults | Description | ||
---|---|---|---|---|---|---|
wss | No | Websocket.Server | Assing SECURE Websocket Server Instance. |