@twilio/flex-ui
Version:
Twilio Flex UI
49 lines (48 loc) • 1.71 kB
TypeScript
/**
* Implmentation to connect to websocket
* @private
*/
export declare class WebSocketConnection {
/**
* Check if we are able to connect to the right server
*
* @param {string} url connection url
* @param {any} obj data to be passed to the server
* @param {callback} dataVerifier function used to verify the data
* @returns {Promise<boolean>} Returns a promise that resolves to a boolean
* @example
*
* WebSocketConnection.remove('wss://localhost:8080',{},(val)=>{
* if(val){
* console.log('connected properly')
* }else{
* console.log('not able to connect properly')
* }
* }))
*/
static checkConnection(url: string, obj: any, dataVerifier: (data: any) => boolean): Promise<boolean>;
/**
* Get a Websocket connection to server
*
* @param {string} url url to websocket
* @param {string|string[]} protocols protocols to be used
* @returns {WebSocket} Return the Websocket object which you can use to communicate with the websocket
* @example
*
* WebSocketConnection.connection('wss://localhost:8080')
*/
static connection(url: string, protocols?: string | string[]): WebSocket;
/**
* Subscribe to the data from the websocket
*
* @param {string} url Url to Subscribe
* @param {any} obj Data to be send
* @param {callback} callback Response data callback
* @example
*
* WebSocketConnection.subcribe('wss://localhost:8080','test',(val)=>{
* console.log(data);
* })
*/
static subcribe(url: string, obj: any, callback: (err: Event, data: any) => boolean): Promise<void>;
}