@duncte123/obs-websocket-js
Version:
OBS Websocket API in Javascript, consumes @Palakis/obs-websocket
47 lines (46 loc) • 1.84 kB
TypeScript
/// <reference types="ws" />
/// <reference types="node" />
import WebSocket from 'isomorphic-ws';
import { EventEmitter } from 'events';
import debug from 'debug';
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: debug.Debugger;
on<K extends keyof EventHandlersDataMap>(event: K, listener: (data: EventHandlersDataMap[K]) => void): this;
emit(event: string | symbol, ...args: any[]): boolean;
connect(args?: 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]>;
}