soundcraft-ui-connection
Version:
Library for controlling the Soundcraft Ui series audio mixers
79 lines (78 loc) • 3.16 kB
TypeScript
import { ConnectionEvent, ConnectionStatus, SoundcraftUIOptions } from './types';
export declare class MixerConnection {
/** time to wait before reconnecting after an error */
private reconnectTime;
/** period time for the keepalive interval messages */
private keepaliveTime;
private socket$;
/**
* closing the socket is not enough to finally end the connection.
* socket$.complete() only works if the socket is open.
* However, if there's a timed reconnect running, it will try to reconnect.
* socket$.complete() will have no effect.
* We have a separate notifier here to destroy the timed reconnect when the user actually wants to close everything
*/
private forceClose$;
/**
* internal message streams.
* can be fed from anywhere inside this class but must not be exposed
*/
private statusSubject$;
private outboundSubject$;
private inboundSubject$;
/**
* active subscription that pipes socket messages into the inbound stream.
* Used to guard against parallel connections when connect() is called multiple times.
*/
private socketSubscription?;
private _status;
/** public message streams */
/** Connection status stream */
status$: import('rxjs').Observable<ConnectionEvent>;
/** Connection status */
get status(): ConnectionStatus;
/** All outbound messages (from client to mixer) */
outbound$: import('rxjs').Observable<string>;
/** All inbound messages (from mixer to client) */
inbound$: import('rxjs').Observable<string>;
/** combined stream of inbound and outbound messages */
allMessages$: import('rxjs').Observable<string>;
constructor(options: SoundcraftUIOptions);
/** Returns a promise that resolves when the connection status becomes Open */
private waitForOpenStatus;
/** Connect to socket and retry if connection lost */
connect(): Promise<void>;
/** Disconnect from socket */
disconnect(): Promise<void>;
/**
* Reconnect to the mixer:
* disconnect, then wait 1 second before connecting again
*/
reconnect(): Promise<void>;
/**
* Send command to the mixer
* @param msg Message to send, e.g. `SETD^i.2.mute^1`
*/
sendMessage(msg: string): void;
/**
* Send a `SETD` command to the mixer.
* `SETD` messages carry numeric (data) values, e.g. fader levels, mute states or gains.
* @param path Parameter path, e.g. `i.2.mute`
* @param value Numeric value to set
*/
setd(path: string, value: number): void;
/**
* Send a `SETD` command with a boolean (on/off) value to the mixer.
* The boolean is converted to the numeric `0`/`1` the protocol expects.
* @param path Parameter path, e.g. `i.2.mute`
* @param value Boolean value to set
*/
setdBool(path: string, value: boolean): void;
/**
* Send a `SETS` command to the mixer.
* `SETS` messages carry string values, e.g. channel names.
* @param path Parameter path, e.g. `i.2.name`
* @param value String value to set
*/
sets(path: string, value: string): void;
}