UNPKG

@duncte123/obs-websocket-js

Version:
46 lines (45 loc) 1.85 kB
/// <reference types="ws" /> /// <reference types="node" /> import WebSocket from 'isomorphic-ws'; import { EventEmitter } from 'events'; import { EventHandlersDataMap, RequestMethodReturnMap, RequestMethodsArgsMap } from './typings/obsWebsocket.js'; export declare type ConnectArgs = { address: string; secure: boolean; password: string; }; export declare abstract class Socket extends EventEmitter { protected connected: boolean; protected socket: WebSocket; protected debug: any; on<K extends keyof EventHandlersDataMap>(event: K, listener: (data: EventHandlersDataMap[K]) => void): this; emit(event: string | symbol, ...args: any[]): boolean; connect(args?: Partial<ConnectArgs>): Promise<void>; /** * Opens a WebSocket connection to an obs-websocket server, but does not attempt any authentication. * * @param {String} address url without ws:// or wss:// prefix. * @param {Boolean} secure whether to us ws:// or wss:// * @returns {Promise} * @private * @return {Promise} on attempted creation of WebSocket connection. */ private connect0; /** * Authenticates to an obs-websocket server. Must already have an active connection before calling this method. * * @param {String} [password=''] authentication string. * @private * @return {Promise} on resolution of authentication call. */ private authenticate; /** * Close and disconnect the WebSocket connection. * * @function * @category request * @return {Promise} */ disconnect(): Promise<void>; abstract send<K extends keyof RequestMethodsArgsMap>(requestType: K, args?: RequestMethodsArgsMap[K] extends object ? RequestMethodsArgsMap[K] : undefined): Promise<RequestMethodReturnMap[K]>; }