@mos-connection/connector
Version:
MOS compliant TCP/IP Socket connection.
85 lines • 3.55 kB
TypeScript
import { IProfiles, MosTypes } from '@mos-connection/model';
import { MosDevice } from './MosDevice';
import { EventEmitter } from 'eventemitter3';
import { IConnectionConfig, IMosConnection, IMOSDeviceConnectionOptions } from './api';
export interface MosConnectionEvents {
rawMessage: (source: string, type: string, message: string) => void;
info: (message: string, data?: any) => void;
warning: (message: string) => void;
error: (error: Error) => void;
}
export declare class MosConnection extends EventEmitter<MosConnectionEvents> implements IMosConnection {
static readonly CONNECTION_PORT_LOWER = 10540;
static readonly CONNECTION_PORT_UPPER = 10541;
static readonly CONNECTION_PORT_QUERY = 10542;
static _nextSocketID: number;
readonly mosTypes: MosTypes;
private _conf;
private _debug;
private _disposed;
private _scheduleCheckProfileValidnessTimeout;
private _lowerSocketServer?;
private _upperSocketServer?;
private _querySocketServer?;
private _incomingSockets;
private _ncsConnections;
private _mosDevices;
private _initialized;
private _isListening;
private _isOpenMediaHotStandby;
private _onConnection?;
/** */
constructor(configOptions: IConnectionConfig);
/**
* Initiate the MosConnection, start accepting connections
*/
init(): Promise<boolean>;
/**
* Establish a new connection to a MOS-device (NCS-server). When established, the new MOS-device will be emitted to this.onConnection()
* @param connectionOptions Connection options
*/
connect(connectionOptions: IMOSDeviceConnectionOptions): Promise<MosDevice>;
/** Callback is called when a new connection is established */
onConnection(cb: (mosDevice: MosDevice) => void): void;
/** True if mosConnection is listening for connections */
get isListening(): boolean;
/** TO BE IMPLEMENTED: True if mosConnection is mos-compliant */
get isCompliant(): boolean;
/** True if mosConnection is configured to accept connections */
get acceptsConnections(): boolean;
/** A list of the profiles mosConnection is currently configured to use */
get profiles(): IProfiles;
/** Close all connections and clear all data */
dispose(): Promise<void>;
/** Return a specific MOS-device */
getDevice(id: string): MosDevice;
/** Get a list of all MOS-devices */
getDevices(): Array<MosDevice>;
disposeMosDevice(mosDevice: MosDevice): Promise<void>;
disposeMosDevice(myMosID: string, theirMosId0: string, theirMosId1: string | null): Promise<void>;
/**
* Do a check if the profile is valid. Throws if not.
* Optionally called after a mosConnection has been set up to ensure that all callbacks have been set up properly.
*/
checkProfileValidness(): void;
/** TO BE IMPLEMENTED */
get complianceText(): string;
setDebug(debug: boolean): void;
private _registerMosDevice;
/** Set up TCP-server */
private _initiateIncomingConnections;
/** */
private _registerIncomingClient;
/** Close socket and clean up */
private _disposeIncomingSocket;
/** Get new unique id */
static get nextSocketID(): string;
private debugTrace;
private _scheduleCheckProfileValidness;
/**
* Checks that all callbacks have been set up properly, according to which MOS-profile have been set in the options.
* throws if something's wrong
*/
private _checkProfileValidness;
}
//# sourceMappingURL=MosConnection.d.ts.map