WebSocketServer class

Web socket based server to be used as streaming transport.

Constructors

WebSocketServer(ISocket, RequestHandler)

Creates a new instance of the WebSocketServer class.

Properties

isConnected

Examines the stored ISocket and returns true if the socket connection is open.

Methods

disconnect()

Stop this server.

send(StreamingRequest)

Task used to send data over this server connection.

start()

Used to establish the connection used by this server and begin listening for incoming messages.

Constructor Details

WebSocketServer(ISocket, RequestHandler)

Creates a new instance of the WebSocketServer class.

new WebSocketServer(socket: ISocket, requestHandler?: RequestHandler)

Parameters

socket
ISocket

The underlying web socket.

requestHandler
RequestHandler

Optional RequestHandler to process incoming messages received by this server.

Property Details

isConnected

Examines the stored ISocket and returns true if the socket connection is open.

boolean isConnected

Property Value

boolean

true if the underlying websocket is ready and availble to send messages, otherwise false.

Method Details

disconnect()

Stop this server.

function disconnect()

send(StreamingRequest)

Task used to send data over this server connection.

function send(request: StreamingRequest): Promise<IReceiveResponse>

Parameters

request
StreamingRequest

The streaming request to send.

Returns

Promise<IReceiveResponse>

A promise that will produce an instance of receive response on completion of the send operation.

start()

Used to establish the connection used by this server and begin listening for incoming messages.

function start(): Promise<string>

Returns

Promise<string>

A promise to handle the server listen operation. This task will not resolve as long as the server is running.