Skip to main content

CloudWebSocketClient

CloudWebSocketClient is a class that handles the WebSocket communication with the cloud node. It is used to send and receive messages from the cloud node

Import

import { CloudWebSocketClient } from '@silencelaboratories/silent-shard-sdk';

Usage

 const couldClient = new CloudWebSocketClient(
'CLOUD_NODE_URL',
false, // boolean indicates if the connection is `WSS` or `WS`
);

Constructors

new CloudWebSocketClient()

new CloudWebSocketClient(url, isSecure, wsClient?): CloudWebSocketClient

Constructor

Parameters

url

string

The URI of the cloud node.

isSecure

boolean

If the connection is secure or not // WSS true / WS false.

wsClient?

IWebSocketClient

The WebSocket client to use. Default is WebSocketClient. If you want to use a custom WebSocket client, you can implement the IWebSocketClient interface. Then you can pass here.

Returns

CloudWebSocketClient

Accessors

isSecure

Get Signature

get isSecure(): boolean

Returns

boolean


url

Get Signature

get url(): string

Returns

string

Methods

close()

close(): Promise<any>

Returns

Promise<any>


connect()

connect(opt): Promise<void>

Parameters

opt

WsOperation

Returns

Promise<void>


read()

read(): Promise<Uint8Array>

Returns

Promise<Uint8Array>


reset()

reset(): void

Returns

void


send()

send(message): void

Parameters

message

string

Returns

void


sendText()

sendText(message): void

Parameters

message

string

Returns

void


waitRemoteClose()

waitRemoteClose(): Promise<undefined | WebSocketCloseEvent>

Returns

Promise<undefined | WebSocketCloseEvent>