UNPKG

camstreamerlib

Version:

Helper library for CamStreamer ACAP applications.

40 lines (39 loc) 1.23 kB
/// <reference types="node" /> /// <reference types="node" /> import * as EventEmitter from 'events'; import { WsOptions } from '../internal/types'; export type WsClientOptions = WsOptions & { address: string; headers?: Record<string, string>; pingInterval?: number; protocol?: string; }; export interface WsClient { on(event: 'open', listener: () => void): this; on(event: 'close', listener: () => void): this; on(event: 'message', listener: (data: Buffer) => void): this; on(event: 'error', listener: (err: Error) => void): this; emit(event: 'open'): boolean; emit(event: 'close'): boolean; emit(event: 'message', data: Buffer): boolean; emit(event: 'error', err: Error): boolean; } export declare class WsClient extends EventEmitter { private user; private pass; private address; private protocol?; private pingInterval; private wsOptions; private digestAddress; private isAlive; private pingTimer?; private ws?; private isClosed; constructor(options: WsClientOptions); open(wwwAuthenticateHeader?: string): void; send(data: Buffer | string): void; close(): void; reconnect(): void; private closeWsConnection; }