active-switching
Version:
NPAW's SDK for CDN Balancing and P2P
43 lines (42 loc) • 1.16 kB
TypeScript
import Emitter from '../Util/Emitter';
/**
* @class
* @description Communication class that uses a websocket,
* it has events for the different expected received messages and the method send
* @extends Emitter
* @exports WsCommunication
*/
export default class WsCommunication extends Emitter {
private readonly _config;
private _ws?;
/**
* @constructs WsCommunication
* @param {string} host Host URL
* @public
*/
constructor(config: P2PConfig);
/**
* Opens the websocket connection
* @returns {WsCommunication} this
* @public
*/
start(): WsCommunication;
/**
* Sends the message using the socket
* @param {trackerMessage} message Message object to be sent as a message by the websocket
* @public
*/
send(message?: trackerMessage): void;
/**
* Function to detect if the websocket has an active connection
* @returns {boolean} if websocket is connected or not
* @public
*/
isConnected(): boolean;
/**
* Callback and function for closed websocket connection
* Removes the listeners
* @public
*/
close(): void;
}