UNPKG

camstreamerlib

Version:

Helper library for CamStreamer ACAP applications.

75 lines (74 loc) 2.19 kB
/// <reference types="node" /> import * as EventEmitter from 'events'; import { WsOptions } from './internal/types'; export type CamScripterOptions = WsOptions; export type TDeclaration = { type?: '' | 'SOURCE' | 'DATA'; namespace: string; key: string; value: string | boolean | number; value_type: 'STRING' | 'INT' | 'BOOL' | 'DOUBLE'; key_nice_name?: string; value_nice_name?: string; }; export type TEventDeclaration = { declaration_id: string; stateless: boolean; declaration: TDeclaration[]; }; export type TEventUndeclaration = { declaration_id: string; }; export type TEventData = { namespace: string; key: string; value: string | boolean | number; value_type: 'STRING' | 'INT' | 'BOOL' | 'DOUBLE'; }; export type TEvent = { declaration_id: string; event_data: TEventData[]; }; export type TResponse = { call_id: number; message: string; }; export type TErrorResponse = { error: string; call_id?: number; }; export interface CamScripterAPICameraEventsGenerator { on(event: 'open', listener: () => void): this; on(event: 'close', listener: () => void): this; on(event: 'error', listener: (err: Error) => void): this; emit(event: 'open'): boolean; emit(event: 'close'): boolean; emit(event: 'error', err: Error): boolean; } export declare class CamScripterAPICameraEventsGenerator extends EventEmitter { private tls; private tlsInsecure; private ip; private port; private user; private pass; private callId; private sendMessages; private timeoutCheckTimer; private wsConnected; private ws; constructor(options?: CamScripterOptions); connect(): void; disconnect(): void; declareEvent(eventDeclaration: TEventDeclaration): Promise<TResponse>; undeclareEvent(eventUndeclaration: TEventUndeclaration): Promise<TResponse>; sendEvent(event: TEvent): Promise<TResponse>; private createWsClient; private incomingWsMessageHandler; private sendMessage; private startMsgsTimeoutCheck; private stopMsgsTimeoutCheck; private reconnectWithError; private reportErr; private reportClose; }