import Emitter from '../Util/Emitter'; import { P2PConfig, trackerMessage } from '../Util/Types'; /** * @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?; private static appendQueryParams; /** * @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; }