Abstract Class: BaseSocketClient
Event bus which publishes using web-sockets.
Constructors
Constructor
new BaseSocketClient(
implementationName,config,pathPrefix):BaseSocketClient
Create a new instance of BaseSocketClient.
Parameters
implementationName
string
The name of the class implementation socket calls.
config
IBaseSocketClientConfig
The configuration for the client.
pathPrefix
string
The default prefix to use if none in configuration.
Returns
BaseSocketClient
Methods
onEvent()
protectedonEvent<T>(event,callback):void
Setup a handler for an event from the socket.
Type Parameters
T
T extends IHttpResponse<any>
Parameters
event
string
The event to look for.
callback
(response) => Promise<void>
The method to call when the event arrives.
Returns
void
offEvent()
protectedoffEvent(event):void
Remove a handler for a event from the socket.
Parameters
event
string
The event to look for.
Returns
void
sendEvent()
protectedsendEvent<T>(event,data):void
Send a event on the socket.
Type Parameters
T
T extends IHttpRequest<any>
Parameters
event
string
The event to send.
data
T
The data to send with the event.
Returns
void
socketConnect()
protectedsocketConnect():boolean
Connect the socket if its not already connected.
Returns
boolean
True if the socket is already connected.
socketDisconnect()
protectedsocketDisconnect():void
Disconnect the socket if its connected.
Returns
void
isConnected()
protectedisConnected():boolean
Is the socket connected.
Returns
boolean
True if the socket is connected.
handleConnected()
abstractprotectedhandleConnected():Promise<void>
Handle the socket connection.
Returns
Promise<void>
handleError()
abstractprotectedhandleError(err):Promise<void>
Handle an error.
Parameters
err
IError
The error to handle.
Returns
Promise<void>