@mos-connection/connector
Version:
MOS compliant TCP/IP Socket connection.
86 lines • 3.02 kB
TypeScript
import { ConnectionType } from './socketConnection';
import { MosSocketClient, CallBackFunction, QueueMessage } from '../connection/mosSocketClient';
import { MosModel } from '@mos-connection/helper';
import { EventEmitter } from 'eventemitter3';
import { ParsedMosMessage } from './mosMessageParser';
export declare const DEFAULT_COMMAND_TIMEOUT = 5000;
export interface ClientDescription {
useHeartbeats: boolean;
heartbeatConnected: boolean;
client: MosSocketClient;
clientDescription: MosModel.PortType;
}
export interface INCSServerConnection {
on(event: 'rawMessage', listener: (type: string, message: string) => void): this;
}
export interface HandedOverQueue {
messages: QueueMessage[];
callbacks: {
[messageId: string]: CallBackFunction;
};
}
export interface NCSServerConnectionEvents {
rawMessage: (...args: any[]) => void;
warning: (str: string) => void;
error: (err: Error) => void;
info: (str: string) => void;
connectionChanged: () => void;
}
/** Handles connections to a NCS (server) */
export declare class NCSServerConnection extends EventEmitter<NCSServerConnectionEvents> implements INCSServerConnection {
private _connected;
private _id;
private _host;
private _timeout;
private _mosID;
private _debug;
private _strict;
private _disposed;
private _clients;
private _emittedConnected;
private _heartBeatsTimer?;
private _heartBeatsInterval;
private _isOpenMediaHotStandby;
constructor(id: string, host: string, mosID: string, timeout: number | undefined, heartbeatsInterval: number | undefined, debug: boolean, strict: boolean, isOpenMediaHotStandby: boolean);
get timeout(): number;
/** Create a MOS client, which talks to */
createClient(clientID: string, port: number, clientDescription: ConnectionType, useHeartbeats: boolean): void;
/** */
removeClient(clientID: string): void;
/** */
disableHeartbeats(): void;
/** */
enableHeartbeats(): void;
/** */
isHearbeatEnabled(): boolean;
setAutoReconnectInterval(interval: number): void;
connect(): void;
/**
* Sends a mos message.
* Returns a Promise which resolves when a MOS reply has been received.
*/
executeCommand(message: MosModel.MosMessage): Promise<ParsedMosMessage>;
setDebug(debug: boolean): void;
get connected(): boolean;
getConnectedStatus(): {
connected: boolean;
status: string;
};
private _getClients;
/** */
get lowerPortClients(): MosSocketClient[];
/** */
get upperPortClients(): MosSocketClient[];
/** */
get queryPortClients(): MosSocketClient[];
get host(): string;
get id(): string;
handOverQueue(otherConnection: NCSServerConnection): void;
receiveQueue(queue: {
[clientId: string]: HandedOverQueue;
}): void;
dispose(): Promise<void>;
private _sendHeartBeats;
private debugTrace;
}
//# sourceMappingURL=NCSServerConnection.d.ts.map