import { EventEmitter } from 'events' ; import { CasparCGSocket } from './lib/CasparCGSocket' ; import { AMCP , AMCPUtil as AMCPUtilNS } from './lib/AMCP' ; import CasparCGSocketResponse = AMCPUtilNS . CasparCGSocketResponse ; import { Enum } from './lib/ServerStateEnum' ; import { IConnectionOptions , ConnectionOptions , Options as OptionsNS } from './lib/AMCPConnectionOptions' ; import QueueMode = OptionsNS . QueueMode ; import CasparCGVersion = OptionsNS . CasparCGVersion ; import { Command as CommandNS } from './lib/AbstractCommand' ; import IAMCPCommand = CommandNS . IAMCPCommand ; import isIAMCPCommand = CommandNS . isIAMCPCommand ; import IAMCPStatus = CommandNS . IAMCPStatus ; import AMCPResponse = CommandNS . AMCPResponse ; import { Param as ParamNS } from './lib/ParamSignature' ; import Param = ParamNS . Param ; import TemplateData = ParamNS . TemplateData ; import { CasparCGSocketStatusEvent , CasparCGSocketCommandEvent , CasparCGSocketResponseEvent , LogEvent , SocketStatusOptions } from './lib/event/Events' ; import { Callback as CallbackNS } from './lib/global/Callback' ; import IBooleanCallback = CallbackNS . IBooleanCallback ; import IErrorCallback = CallbackNS . IErrorCallback ; import IStringCallback = CallbackNS . IStringCallback ; import ISocketStatusCallback = CallbackNS . ISocketStatusCallback ; import { Config as ConfigNS } from './lib/Config' ; import CasparCGConfig = ConfigNS . Intermediate . CasparCGConfig ; import { Response as ResponseNS } from './lib/ResponseParsers' ; import CasparCGPaths = ResponseNS . CasparCGPaths ; export enum Priority { LOW = 0 , NORMAL = 1 , HIGH = 2 } /**
 * CasparCG Protocols
 */ export namespace CasparCGProtocols { /**
     * CasparCG Protocol version 2.1
     */ export namespace v2_1 { /**
         * AMCP Media-commands
         */ export interface IVideo { loadbg ( channel , layer , clip , loop ? , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , seek ? , length ? , filter ? , auto ? ) : Promise < IAMCPCommand > ; loadbgAuto ( channel , layer , clip , loop ? , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , seek ? , length ? , filter ? ) : Promise < IAMCPCommand > ; load ( channel , layer , clip , loop ? , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , seek ? , length ? , filter ? ) : Promise < IAMCPCommand > ; play ( channel , layer ? , clip ? , loop ? , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , seek ? , length ? , filter ? ) : Promise < IAMCPCommand > ; pause ( channel , layer ? ) : Promise < IAMCPCommand > ; resume ( channel , layer ? ) : Promise < IAMCPCommand > ; stop ( channel , layer ? ) : Promise < IAMCPCommand > ; } /**
         * AMCP In/Out-commands
         */ export interface IInputOutput { loadDecklinkBg ( channel , layer , device , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , length ? , filter ? , format ? , channelLayout ? , auto ? ) : Promise < IAMCPCommand > ; loadDecklinkBgAuto ( channel , layer , device , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , length ? , filter ? , format ? , channelLayout ? ) : Promise < IAMCPCommand > ; loadDecklink ( channel , layer , device , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , length ? , filter ? , format ? , channelLayout ? ) : Promise < IAMCPCommand > ; playDecklink ( channel , layer ? , device ? , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , length ? , filter ? , format ? , channelLayout ? ) : Promise < IAMCPCommand > ; loadHtmlPageBg ( channel , layer , url , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , seek ? , length ? , filter ? , auto ? ) : Promise < IAMCPCommand > ; loadHtmlPageBgAuto ( channel , layer , url , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? ) : Promise < IAMCPCommand > ; loadHtmlPage ( channel , layer , url , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? ) : Promise < IAMCPCommand > ; playHtmlPage ( channel , layer ? , url ? , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? ) : Promise < IAMCPCommand > ; } /**
         * AMCP Template-commands
         */ export interface ICG { cgAdd ( channel , layer , flashLayer , templateName , playOnLoad , data ? ) : Promise < IAMCPCommand > ; cgPlay ( channel , layer , flashLayer ) : Promise < IAMCPCommand > ; cgStop ( channel , layer , flashLayer ) : Promise < IAMCPCommand > ; cgNext ( channel , layer , flashLayer ) : Promise < IAMCPCommand > ; cgRemove ( channel , layer , flashLayer ) : Promise < IAMCPCommand > ; cgClear ( channel , layer ? ) : Promise < IAMCPCommand > ; cgUpdate ( channel , layer , flashLayer , data ) : Promise < IAMCPCommand > ; cgInvoke ( channel , layer , flashLayer , methodName ) : Promise < IAMCPCommand > ; } /**
         * AMCP Mixer-commands
         */ export interface IMixer { mixerKeyer ( channel , layer ? , state ? , defer ? ) : Promise < IAMCPCommand > ; mixerKeyerDeferred ( channel , layer ? , state ? ) : Promise < IAMCPCommand > ; getMixerStatusKeyer ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerChroma ( channel , layer ? , keyer ? , threshold ? , softness ? , spill ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerChromaDeferred ( channel , layer ? , keyer ? , threshold ? , softness ? , spill ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusChroma ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerBlend ( channel , layer ? , blendmode ? , defer ? ) : Promise < IAMCPCommand > ; mixerBlendDeferred ( channel , layer ? , blendmode ? ) : Promise < IAMCPCommand > ; getMixerStatusBlend ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerOpacity ( channel , layer ? , opacity ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerOpacityDeferred ( channel , layer ? , opacity ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusOpacity ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerBrightness ( channel , layer ? , brightness ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerBrightnessDeferred ( channel , layer ? , brightness ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusBrightness ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerSaturation ( channel , layer ? , saturation ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerSaturationDeferred ( channel , layer ? , saturation ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusSaturation ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerBrightness ( channel , layer ? , contrast ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerContrastDeferred ( channel , layer ? , contrast ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusContrast ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerLevels ( channel , layer ? , minInput ? , maxInput ? , gamma ? , minOutput ? , maxOutput ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerLevelsDeferred ( channel , layer ? , minInput ? , maxInput ? , gamma ? , minOutput ? , maxOutput ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusLevels ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerFill ( channel , layer ? , x ? , y ? , xScale ? , yScale ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerFillDeferred ( channel , layer ? , x ? , y ? , xScale ? , yScale ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusFill ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerClip ( channel , layer ? , x ? , y ? , width ? , height ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerClipDeferred ( channel , layer ? , x ? , y ? , width ? , height ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusClip ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerAnchor ( channel , layer ? , x ? , y ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerAnchorDeferred ( channel , layer ? , x ? , y ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusAnchor ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerCrop ( channel , layer ? , left ? , top ? , right ? , bottom ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerCropDeferred ( channel , layer ? , left ? , top ? , right ? , bottom ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusCrop ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerRotation ( channel , layer ? , rotation ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerRotationDeferred ( channel , layer ? , rotation ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusRotation ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerPerspective ( channel , layer ? , topLeftX ? , topLeftY ? , topRightX ? , topRightY ? , bottomRightX ? , bottomRightY ? , bottomLeftX ? , bottomLeftY ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerPerspectiveDeferred ( channel , layer ? , topLeftX ? , topLeftY ? , topRightX ? , topRightY ? , bottomRightX ? , bottomRightY ? , bottomLeftX ? , bottomLeftY ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusPerspective ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerMipmap ( channel , layer ? , state ? , defer ? ) : Promise < IAMCPCommand > ; mixerMipmapDeferred ( channel , layer ? , state ? ) : Promise < IAMCPCommand > ; getMixerStatusMipmap ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerVolume ( channel , layer ? , volume ? , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerVolumeDeferred ( channel , layer ? , volume ? , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; getMixerStatusVolume ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerMastervolume ( channel , mastervolume ? , defer ? ) : Promise < IAMCPCommand > ; mixerMastervolumeDeferred ( channel , mastervolume ? ) : Promise < IAMCPCommand > ; getMixerStatusMastervolume ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerStraightAlphaOutput ( channel , layer ? , state ? , defer ? ) : Promise < IAMCPCommand > ; mixerStraightAlphaOutputDeferred ( channel , layer ? , state ? ) : Promise < IAMCPCommand > ; getMixerStatusStraightAlphaOutput ( channel , layer ? ) : Promise < IAMCPCommand > ; mixerGrid ( channel , resolution , transitionDuration ? , transitionEasing ? , defer ? ) : Promise < IAMCPCommand > ; mixerGridDeferred ( channel , resolution , transitionDuration ? , transitionEasing ? ) : Promise < IAMCPCommand > ; mixerCommit ( channel ) : Promise < IAMCPCommand > ; mixerClear ( channel , layer ? ) : Promise < IAMCPCommand > ; } /**
         * AMCP Channel-commands
         */ export interface IChannel { clear ( channel , layer ? ) : Promise < IAMCPCommand > ; print ( channel ) : Promise < IAMCPCommand > ; lock ( channel , action , lockPhrase ? ) : Promise < IAMCPCommand > ; channelGrid ( ) : Promise < IAMCPCommand > ; glGC ( ) : Promise < IAMCPCommand > ; addDecklink ( channel , device , id ? ) : Promise < IAMCPCommand > ; addImage ( channel , fileName , id ? ) : Promise < IAMCPCommand > ; addFile ( channel , fileName , id ? ) : Promise < IAMCPCommand > ; addStream ( channel , uri , params , id ? ) : Promise < IAMCPCommand > ; remove ( channel , id ) : Promise < IAMCPCommand > ; removeDecklink ( channel , device ) : Promise < IAMCPCommand > ; removeImage ( channel , fileName ) : Promise < IAMCPCommand > ; removeFile ( channel , fileName ) : Promise < IAMCPCommand > ; removeStream ( channel , uri ) : Promise < IAMCPCommand > ; } /**
         * AMCP Template Data-commands
         */ export interface IData { dataStore ( fileName , data ) : Promise < IAMCPCommand > ; dataRetrieve ( fileName ) : Promise < IAMCPCommand > ; dataList ( ) : Promise < IAMCPCommand > ; dataRemove ( fileName ) : Promise < IAMCPCommand > ; } /**
         * AMCP Thumbnail-commands
         */ export interface IThumbnail { thumbnailList ( subFolder ? ) : Promise < IAMCPCommand > ; thumbnailRetrieve ( fileName ) : Promise < IAMCPCommand > ; thumbnailGenerate ( fileName ) : Promise < IAMCPCommand > ; thumbnailGenerateAll ( ) : Promise < IAMCPCommand > ; } /**
         * AMCP Query-commands
         */ export interface IQuery { cinf ( fileName ) : Promise < IAMCPCommand > ; cls ( subFolder ? ) : Promise < IAMCPCommand > ; fls ( ) : Promise < IAMCPCommand > ; tls ( subFolder ? ) : Promise < IAMCPCommand > ; version ( component ? ) : Promise < IAMCPCommand > ; info ( channel ? , layer ? ) : Promise < IAMCPCommand > ; infoTemplate ( template ) : Promise < IAMCPCommand > ; infoConfig ( ) : Promise < IAMCPCommand > ; infoPaths ( ) : Promise < IAMCPCommand > ; infoSystem ( ) : Promise < IAMCPCommand > ; infoServer ( ) : Promise < IAMCPCommand > ; infoQueues ( ) : Promise < IAMCPCommand > ; infoThreads ( ) : Promise < IAMCPCommand > ; infoDelay ( channel , layer ? ) : Promise < IAMCPCommand > ; cgInfo ( channel , layer ? , flashLayer ? ) : Promise < IAMCPCommand > ; templateHostInfo ( channel , layer ? ) : Promise < IAMCPCommand > ; glInfo ( ) : Promise < IAMCPCommand > ; logLevel ( level ) : Promise < IAMCPCommand > ; logCategory ( category , enabled ) : Promise < IAMCPCommand > ; logCalltrace ( enabled ) : Promise < IAMCPCommand > ; logCommunication ( enabled ) : Promise < IAMCPCommand > ; diag ( ) : Promise < IAMCPCommand > ; help ( command ? ) : Promise < IAMCPCommand > ; getCommands ( ) : Promise < IAMCPCommand > ; helpProducer ( producer ? ) : Promise < IAMCPCommand > ; getProducers ( ) : Promise < IAMCPCommand > ; helpConsumer ( consumer ? ) : Promise < IAMCPCommand > ; getConsumers ( ) : Promise < IAMCPCommand > ; } /**
         * AMCP Operation-commands
         */ export interface IOperation { bye ( ) : Promise < IAMCPCommand > ; kill ( ) : Promise < IAMCPCommand > ; restart ( ) : Promise < IAMCPCommand > ; } export interface AMCP extends IVideo , IInputOutput , ICG , IMixer , IChannel , IData , IThumbnail , IQuery , IOperation { } } } /**
 * CasparCG Interface
 */ export interface ICasparCGConnection { connectionOptions : ConnectionOptions ; connected : boolean ; connectionStatus : SocketStatusOptions ; readonly commandQueueLength : number ; getCasparCGConfig ( refresh ) : Promise < CasparCGConfig > ; getCasparCGPaths ( refresh ) : Promise < CasparCGPaths > ; getCasparCGVersion ( refresh ) : Promise < CasparCGVersion > ; removeQueuedCommand ( id ) : boolean ; connect ( options ? ) : void ; disconnect ( ) : void ; createCommand ( command ) : IAMCPCommand | undefined ; createCommand ( commandString , ... params ) : IAMCPCommand | undefined ; queueCommand ( command , priority ) : Promise < IAMCPCommand > ; do ( command ) : Promise < IAMCPCommand > ; do ( commandString , ... params ) : Promise < IAMCPCommand > ; doNow ( command ) : Promise < IAMCPCommand > ; doNow ( commandString , ... params ) : Promise < IAMCPCommand > ; doLater ( command ) : Promise < IAMCPCommand > ; doLater ( commandString , ... params ) : Promise < IAMCPCommand > ; } /**
 * The main object and entrypoint for all interactions. `CasparCG` allows for flexible configuration, re-configuration and events/callbacks.
 * It implements all [[AMCP]] commands as high-level methods with convenient interfaces.
 *
 * There is a single [[CasparCGSocket]] pr. `CasparCG` object.
 * `CasparCG` should be the only public interface to interact directly with.
 */ export class CasparCG extends EventEmitter implements ICasparCGConnection , ConnectionOptions , CasparCGProtocols . v2_1 . AMCP { /**
     * Try to connect upon creation.
     */ public autoConnect : boolean | undefined = undefined ; /**
     * Setting this to true will investigate all connections to assess if the server is freshly booted, or have been used before the connection
     */ public virginServerCheck : boolean | undefined = undefined ; /**
     * Setting this to true will print out logging to the `Console`, in addition to the optinal [[onLog]] and [[LogEvent.LOG]]
     */ public debug : boolean | undefined = undefined ; /**
     * Callback for all logging.
     */ public onLog : IStringCallback | undefined = undefined ; /**
     * Callback for all status updates from the `CasparCGSocket`.
     */ public onConnectionStatus : ISocketStatusCallback | undefined = undefined ; /**
     * Callback for status updates from the `CasparCGSocket` if the `connected` property changes value.
     */ public onConnectionChanged : IBooleanCallback | undefined = undefined ; /**
     * Callback for status updates from the `CasparCGSocket` if the `connected` property is set to `true`.
     */ public onConnected : IBooleanCallback | undefined = undefined ; /**
     * Callback for status updates from the `CasparCGSocket` if the `connected` property is set to `false`.
     */ public onDisconnected : IBooleanCallback | undefined = undefined ; /**
     * Callback for general errors
     */ public onError : IErrorCallback | undefined = undefined ; todo private _queueMode : QueueMode ; private _connected : boolean = false ; private _host : string ; private _port : number ; private _autoReconnect : boolean ; private _autoReconnectInterval : number ; private _autoReconnectAttempts : number ; private _socket : CasparCGSocket ; private _queuedCommands : Array < IAMCPCommand > = [ ] ; private _queuedCommandsLowPriority : Array < IAMCPCommand > = [ ] ; private _queuedCommandsHighPriority : Array < IAMCPCommand > = [ ] ; private _sentCommands : { [ token ] : IAMCPCommand ; } = { } ; private _configPromise : Promise < CasparCGConfig > ; private _pathsPromise : Promise < CasparCGPaths > ; private _versionPromise : Promise < CasparCGVersion > ; private _userConfigServerVersion : CasparCGVersion ; param host param port param options public constructor ( host ? , port ? ) ; /**
     * Callbacks and events after constructor:
     *
     * ```
     * var con = new CasparCG({host: "192.168.0.1", autoConnect: false});
     * // host = 192.168.0.1, port = 5250, autoConnect = false ...
  *
     * // add onLog callback after constructor
     * con.onLog = function(logMessage){ console.log(logMessage); };
  *
     * // add eventlistener to the conenction event before connecting
     * con.on(CasparCGSocketStatusEvent.CONNECTED, onConnection(event));
  *
  * con.connect();
     * ```
     * Callback in constructor:
     *
     * ```
     * var con = new CasparCG({host: "192.168.0.1", onConnect: onConnectedCallback});
     * // Connection callbacks can be set in the constructor and will be registered before autoConnect invokes.
     * // This ensures that you recieve all callbacks
     * ```
     * Inline function syntax:
     *
     * ```
     * var con = new CasparCG({host: "192.168.0.1", onConnect: function(connected) {
     * // do something once we get connected
     * console.log("Are we conencted?", connected)
     * 	}
     * });
     * ```
     * Inline fat arrow syntax:
     *
     * ```
     * var con = new CasparCG({host: "192.168.0.1", onConnect: (connected) => {
     * // do something once we get connected
     * ("Are we conencted?", connected)
     * 	}
     * });
     * ```
     *
     */ public constructor ( options ) ; public constructor ( hostOrOptions ? , port ? ) { super ( ) ; let options ; if ( typeof hostOrOptions === 'object' ) { options = new ConnectionOptions ( hostOrOptions ) ; } else { options = new ConnectionOptions ( hostOrOptions , port ) ; } if ( port && ( port !== options . port ) ) { options . port = port ; } this . _createNewSocket ( options ) ; if ( this . autoConnect ) { this . connect ( ) ; } } param options public connect ( options ? ) { if ( options ) { this . _createNewSocket ( options ) ; } if ( this . _socket ) { this . _socket . connect ( ) ; } } /**
     * Disconnects and disposes the [[CasparCGSocket]] connection.
     */ public disconnect ( ) { if ( this . _socket ) { this . _socket . disconnect ( ) ; } } /**
     *
     */ public reconnect ( ) { this . _createNewSocket ( undefined , true ) ; this . connect ( ) ; } /**
     *
     */ public get host ( ) : string { return this . _host ; } /**
     * Setting the `host` will create a new [[CasparCGSocket]] connection.
     *
     * The new `CasparCGSocket` will `autoConnect` if the old socket was either successfully connected, or currently reconnecting. Changing the host resets the number of [[CasparCG.autoReconnectAttempts]].
     */ public set host ( host ) { if ( this . _host !== host ) { this . _host = host ; let shouldReconnect = this . connected ; this . _createNewSocket ( ) ; if ( shouldReconnect ) { this . connect ( ) ; } } } /**
     *
     */ public get port ( ) : number { return this . _port ; } /**
     * Setting the `port` will create a new [[CasparCGSocket]] connection.
     *
     * The new `CasparCGSocket` will `autoConnect` if the old socket was either successfully connected, or currently reconnecting. Changing the host resets the number of [[CasparCG.autoReconnectAttempts]].
     */ public set port ( port ) { if ( this . _port !== port ) { this . _port = port ; let shouldReconnect = this . connected ; this . _createNewSocket ( ) ; if ( shouldReconnect ) { this . connect ( ) ; } } } /**
     * Try to reconnect in case of unintentionally loss of connection, or in case of failed connection in the first place.
     */ public get autoReconnect ( ) : boolean { return this . _autoReconnect ; } /**
     *
     */ public set autoReconnect ( autoReconnect ) { this . _autoReconnect = autoReconnect ; if ( this . _socket ) { this . _socket . autoReconnect = this . _autoReconnect ; } } /**
     * Timeout in milliseconds between each connection attempt during reconnection.
     */ public get autoReconnectInterval ( ) : number { return this . _autoReconnectInterval ; } /**
     *
     */ public set autoReconnectInterval ( autoReconnectInterval ) { this . _autoReconnectInterval = autoReconnectInterval ; if ( this . _socket ) { this . _socket . autoReconnectInterval = this . _autoReconnectInterval ; } } /**
     * Max number of attempts of connection during reconnection. This value resets once the reconnection is over (either in case of successfully reconnecting, changed connection properties such as `host` or `port` or by being manually cancelled).
     */ public get autoReconnectAttempts ( ) : number { return this . _autoReconnectAttempts ; } /**
     *
     */ public set autoReconnectAttempts ( autoReconnectAttempts ) { this . _autoReconnectAttempts = autoReconnectAttempts ; if ( this . _socket ) { this . _socket . autoReconnectAttempts = this . _autoReconnectAttempts ; } } /**
     *
     */ public get connectionOptions ( ) : ConnectionOptions { let options = new ConnectionOptions ( { } ) ; for ( let key in options ) { if ( this . hasOwnProperty ( key ) || CasparCG . hasOwnProperty ( key ) ) { ( options as any ) [ key ] = ( this as any ) [ key ] ; } } return options ; } /**
     *
     */ public get connected ( ) : boolean { return this . _connected || false ; } /**
     *
     */ public get connectionStatus ( ) : SocketStatusOptions { return this . _socket . socketStatus ; } /**
     *
     */ public set serverVersion ( version ) { if ( version ) { this . _userConfigServerVersion = version ; } } /**
     *
     */ public get serverVersion ( ) : CasparCGVersion | undefined { if ( this . _userConfigServerVersion ) { return this . _userConfigServerVersion ; } return undefined ; } public get queueMode ( ) : QueueMode { return this . _queueMode ; } public set queueMode ( mode ) { if ( this . _queueMode === QueueMode . SEQUENTIAL && mode === QueueMode . SALVO && Object . keys ( this . _sentCommands ) . length ) { this . _log ( 'Warning: setting queuemode to SALVO while there is a sequential command being sent will return undocumente behaviour!' ) ; } this . _queueMode = mode ; if ( this . _socket ) { this . _socket . queueMode = mode ; } } /**
     *
     */ public get commandQueueLength ( ) : number { return this . _queuedCommands . length + this . _queuedCommandsLowPriority . length + this . _queuedCommandsHighPriority . length ; } todo todo public do ( command ) ; public do ( commandString , ... params ) ; public do ( commandOrString , ... params ) { let command = this . createCommand ( commandOrString , ... params ) ; if ( command ) { return this . queueCommand ( command ) ; } return Promise . reject ( 'Could not create command instance' ) ; } todo todo public doNow ( command ) ; public doNow ( commandString , ... params ) ; public doNow ( commandOrString , ... params ) { let command = this . createCommand ( commandOrString , ... params ) ; if ( command ) { return this . queueCommand ( command , Priority . HIGH ) ; } return Promise . reject ( 'Could not create command instance' ) ; } todo todo public doLater ( command ) ; public doLater ( commandString , ... params ) ; public doLater ( commandOrString , ... params ) { let command = this . createCommand ( commandOrString , ... params ) ; if ( command ) { return this . queueCommand ( command , Priority . LOW ) ; } return Promise . reject ( 'Could not create command instance' ) ; } /**
     *
     */ public createCommand ( commandOrString , ... params ) { let command ; try { if ( isIAMCPCommand ( commandOrString ) ) { command = commandOrString ; } else { if ( AMCP . hasOwnProperty ( commandOrString ) ) { if ( ( AMCP as any ) [ commandOrString ] ) { command = new ( AMCP as any ) ( commandOrString ) ( params ) ; } else { throw new Error ( 'Invalid command constructor' ) ; } } } if ( ! command || ! command . validateParams ( ) ) { throw new Error ( 'Invalid command parameters' ) ; } return command ; } catch ( error ) { this . _log ( error ) ; } return undefined ; } /**
     *
     */ public queueCommand ( command , priority = Priority . NORMAL ) { let commandPromise ; let commandPromiseArray = [ new Promise < IAMCPCommand > ( ( resolve , reject ) => { command . resolve = resolve ; command . reject = reject ; } ) ] ; if ( command . name === 'ScheduleSetCommand' ) { let subCommand = command . getParam ( 'command' ) as IAMCPCommand ; commandPromiseArray . push ( new Promise < IAMCPCommand > ( ( resolve , reject ) => { subCommand . resolve = resolve ; subCommand . reject = reject ; } ) ) ; } commandPromise = Promise . all ( commandPromiseArray ) ; commandPromise . catch ( ( error ) => { this . _log ( new Error ( 'Command error: ' + error . toString ( ) ) ) ; } ) ; switch ( priority ) { case Priority . NORMAL : this . _queuedCommands . push ( command ) ; break ; case Priority . HIGH : this . _queuedCommandsHighPriority . push ( command ) ; break ; case Priority . LOW : this . _queuedCommandsLowPriority . push ( command ) ; break ; } this . _log ( `New command added, "${ command . name }". ${ this . commandQueueLength } command(s) in command queues.` ) ; command . status = IAMCPStatus . Queued ; this . _executeNextCommand ( ) ; return new Promise ( ( outerResolve , outerReject ) => { commandPromise . then ( ( cmds ) => [ outerResolve ( cmds [ cmds . length - 1 ] ) ] ) . catch ( ( err ) => { outerReject ( err ) ; } ) ; } ) ; } todo public removeQueuedCommand ( id ) { let removed ; for ( let i = 0 ; i < this . _queuedCommands . length ; i ++ ) { let o = this . _queuedCommands [ i ] ; if ( o . id === id ) { removed = this . _queuedCommands . splice ( i , 1 ) ; this . _log ( `Command removed, "${ removed [ 0 ] . name }". ${ this . commandQueueLength } command(s) left in command queues.` ) ; break ; } } if ( ! removed ) { for ( let i = 0 ; i < this . _queuedCommandsHighPriority . length ; i ++ ) { let o = this . _queuedCommandsHighPriority [ i ] ; if ( o . id === id ) { removed = this . _queuedCommandsHighPriority . splice ( i , 1 ) ; this . _log ( `Command removed, "${ removed [ 0 ] . name }". ${ this . commandQueueLength } command(s) left in command queues.` ) ; break ; } } } if ( ! removed ) { for ( let i = 0 ; i < this . _queuedCommandsLowPriority . length ; i ++ ) { let o = this . _queuedCommandsLowPriority [ i ] ; if ( o . id === id ) { removed = this . _queuedCommandsLowPriority . splice ( i , 1 ) ; this . _log ( `Command removed, "${ removed [ 0 ] . name }". ${ this . commandQueueLength } command(s) left in command queues.` ) ; break ; } } } return Array . isArray ( removed ) && removed . length > 0 ; } /***/ public getCasparCGConfig ( refresh = false ) { if ( ! this . _configPromise || refresh ) { this . _configPromise = new Promise < CasparCGConfig > ( ( resolve , reject ) => { this . infoConfig ( ) . then ( ( response ) => { resolve ( response . response . data as CasparCGConfig ) ; } ) . catch ( reject ) ; } ) ; } return this . _configPromise ; } /***/ public getCasparCGPaths ( refresh = false ) { if ( ! this . _pathsPromise || refresh ) { this . _pathsPromise = new Promise < CasparCGPaths > ( ( resolve , reject ) => { this . infoPaths ( ) . then ( ( response ) => { resolve ( response . response . data as CasparCGPaths ) ; } ) . catch ( reject ) ; } ) ; } return this . _pathsPromise ; } /***/ public getCasparCGVersion ( refresh = false ) { if ( ! this . _versionPromise || refresh ) { if ( this . _userConfigServerVersion ) { this . _versionPromise = new Promise < CasparCGVersion > ( ( resolve ) => resolve ( this . _userConfigServerVersion ) ) ; } else { this . _versionPromise = new Promise < CasparCGVersion > ( ( resolve , reject ) => { this . doNow ( new AMCP . VersionCommand ( { component : Enum . Version . SERVER } ) ) . then ( ( response ) => { let versionString = response . response . data . toString ( ) . slice ( 0 , 5 ) ; let version = CasparCGVersion . V2xx ; switch ( versionString ) { case '2.0.7' : version = CasparCGVersion . V207 ; break ; case '2.1.0' : version = CasparCGVersion . V210 ; break ; } resolve ( version ) ; } ) . catch ( reject ) ; } ) ; } } return this . _versionPromise ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOADBG>
     */ public loadbg ( channel , layer , clip , loop ? , transition ? , transitionDuration ? , transitionEasing ? , transitionDirection ? , seek ? , length ? , filter ? , auto ? , channelLayout ? , clearOn404 ? ) ; public loadbg ( channel , layer , clip , loop ? , transition ? , transitionMaskFile ? , transitionStingDuration ? , transitionOverlay ? , seek ? , length ? , filter ? , auto ? , channelLayout ? , clearOn404 ? ) ; public loadbg ( channel , layer , clip , loop ? , transition ? , transitionStingProperties ? , transitionStingDuration ? , transitionOverlay ? , seek ? , length ? , filter ? , auto ? , channelLayout ? , clearOn404 ? ) ; public loadbg ( channel , layer = NaN , clip , loop ? , transition ? , transitionDurationOrMaskFileOrProps ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , seek ? , length ? , filter ? , auto ? , channelLayout ? , clearOn404 ? ) { return this . do ( new AMCP . LoadbgCommand ( { channel : channel , layer : layer , clip : clip , loop : loop , transition : transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFileOrProps , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , seek : seek , length : length , filter : filter , auto : auto , channelLayout , clearOn404 } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOADBG>
     */ public loadbgAuto ( channel , layer , clip , loop ? , transition ? , transitionDuration ? , transitionEasing ? , transitionDirection ? , seek ? , length ? , filter ? , channelLayout ? , clearOn404 ? ) ; public loadbgAuto ( channel , layer , clip , loop ? , transition ? , transitionMaskFile ? , transitionStingDuration ? , transitionOverlay ? , seek ? , length ? , filter ? , channelLayout ? , clearOn404 ? ) ; public loadbgAuto ( channel , layer , clip , loop ? , transition ? , transitionStingProperties ? , transitionStingDuration ? , transitionOverlay ? , seek ? , length ? , filter ? , channelLayout ? , clearOn404 ? ) ; public loadbgAuto ( channel , layer = NaN , clip , loop ? , transition ? , transitionDurationOrMaskFileOrProps ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , seek ? , length ? , filter ? , channelLayout ? , clearOn404 ? ) { return this . do ( new AMCP . LoadbgCommand ( { channel : channel , layer : layer , clip : clip , loop : loop , transition : transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFileOrProps , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , seek : seek , length : length , filter : filter , auto : true , channelLayout , clearOn404 } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOAD>
     */ public load ( channel , layer , clip , loop ? , transition ? , transitionDuration ? , transitionEasing ? , transitionDirection ? , seek ? , length ? , filter ? , channelLayout ? , clearOn404 ? ) ; public load ( channel , layer , clip , loop ? , transition ? , transitionMaskFile ? , transitionStingDuration ? , transitionOverlay ? , seek ? , length ? , filter ? , channelLayout ? , clearOn404 ? ) ; public load ( channel , layer , clip , loop ? , transition ? , transitionStingProperties ? , transitionStingDuration ? , transitionOverlay ? , seek ? , length ? , filter ? , channelLayout ? , clearOn404 ? ) ; public load ( channel , layer = NaN , clip , loop ? , transition ? , transitionDurationOrMaskFileOrProps ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , seek ? , length ? , filter ? , channelLayout ? , clearOn404 ? ) { return this . do ( new AMCP . LoadCommand ( { channel : channel , layer : layer , clip : clip , loop : loop , transition : transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFileOrProps , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , seek : seek , length : length , filter : filter , channelLayout , clearOn404 } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#PLAY>
     */ public play ( channel , layer , clip , loop ? , transition ? , transitionDuration ? , transitionEasing ? , transitionDirection ? , seek ? , length ? , filter ? , channelLayout ? , clearOn404 ? ) ; public play ( channel , layer , clip , loop ? , transition ? , transitionMaskFile ? , transitionStingDuration ? , transitionOverlay ? , seek ? , length ? , filter ? , channelLayout ? , clearOn404 ? ) ; public play ( channel , layer , clip , loop ? , transition ? , transitionStingProperties ? , transitionStingDuration ? , transitionOverlay ? , seek ? , length ? , filter ? , channelLayout ? , clearOn404 ? ) ; public play ( channel , layer = NaN , clip ? , loop ? , transition ? , transitionDurationOrMaskFileOrStingProps ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , seek ? , length ? , filter ? , channelLayout ? , clearOn404 ? ) { return this . do ( new AMCP . PlayCommand ( { channel , layer , clip , loop , transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFileOrStingProps , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , seek , length , filter , channelLayout , clearOn404 } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOADBG>
     */ public loadDecklinkBg ( channel , layer = NaN , device , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , length ? , filter ? , format ? , channelLayout ? , auto ? ) { return this . do ( new AMCP . LoadDecklinkBgCommand ( { channel : channel , layer : layer , device : device , transition : transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFile , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , length : length , filter : filter , format : format , channelLayout : channelLayout , auto : auto } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOADBG>
     */ public loadDecklinkBgAuto ( channel , layer = NaN , device , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , length ? , filter ? , format ? , channelLayout ? ) { return this . do ( new AMCP . LoadDecklinkBgCommand ( { channel : channel , layer : layer , device : device , transition : transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFile , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , length : length , filter : filter , format : format , channelLayout : channelLayout , auto : true } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOAD>
     */ public loadDecklink ( channel , layer = NaN , device , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , length ? , filter ? , format ? , channelLayout ? ) { return this . do ( new AMCP . LoadDecklinkCommand ( { channel : channel , layer : layer , device : device , transition : transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFile , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , length : length , filter : filter , format : format , channelLayout : channelLayout } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#PLAY>
     */ public playDecklink ( channel , layer = NaN , device ? , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , length ? , filter ? , format ? , channelLayout ? ) { return this . do ( new AMCP . PlayDecklinkCommand ( { channel : channel , layer : layer , device : device , transition : transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFile , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , length : length , filter : filter , format : format , channelLayout : channelLayout } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOADBG>
     */ public loadRouteBg ( channel , layer = NaN , route , mode , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , length ? , filter ? , format ? , channelLayout ? , auto ? , framesDelay ? ) { return this . do ( new AMCP . LoadRouteBgCommand ( { channel , layer , route , mode , transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFile , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , length : length , filter : filter , format : format , channelLayout : channelLayout , auto : auto , framesDelay } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOADBG>
     */ public loadRouteBgAuto ( channel , layer = NaN , route , mode , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , length ? , filter ? , format ? , channelLayout ? , framesDelay ? ) { return this . do ( new AMCP . LoadRouteBgCommand ( { channel , layer , route , mode , transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFile , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , length : length , filter : filter , format : format , channelLayout : channelLayout , auto : true , framesDelay } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOAD>
     */ public loadRoute ( channel , layer = NaN , route , mode , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , length ? , filter ? , format ? , channelLayout ? , framesDelay ? ) { return this . do ( new AMCP . LoadRouteCommand ( { channel , layer , route , mode , transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFile , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , length : length , filter : filter , format : format , channelLayout : channelLayout , framesDelay } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#PLAY>
     */ public playRoute ( channel , layer = NaN , route , mode , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , length ? , filter ? , format ? , channelLayout ? , framesDelay ? ) { return this . do ( new AMCP . PlayRouteCommand ( { channel , layer , route , mode , transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFile , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , length : length , filter : filter , format : format , channelLayout : channelLayout , framesDelay } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOADBG>
     */ public loadHtmlPageBg ( channel , layer = NaN , clip , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? , auto ? ) { return this . do ( new AMCP . LoadHtmlPageBgCommand ( { channel : channel , layer : layer , clip : clip , transition : transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFile , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , auto : auto } ) ) ; } /**
     *
     */ public loadHtmlPageBgAuto ( channel , layer = NaN , url , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? ) { return this . do ( new AMCP . LoadHtmlPageBgCommand ( { channel : channel , layer : layer , url : url , transition : transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFile , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) , auto : true } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOAD>
     */ public loadHtmlPage ( channel , layer = NaN , url , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? ) { return this . do ( new AMCP . LoadHtmlPageCommand ( { channel : channel , layer : layer , url : url , transition : transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFile , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#PLAY>
     */ public playHtmlPage ( channel , layer ? ) ; public playHtmlPage ( channel , layer = NaN , url ? , transition ? , transitionDurationOrMaskFile ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? ) { return this . do ( new AMCP . PlayHtmlPageCommand ( { channel : channel , layer : layer , url : url , transition : transition , ... this . _createTransitionOptionsObject ( transition , transitionDurationOrMaskFile , transitionEasingOrStingDuration , transitionDirectionOrOverlay ) } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#PAUSE>
     */ public pause ( channel , layer ? ) { return this . do ( new AMCP . PauseCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#RESUME>
     */ public resume ( channel , layer ? ) { return this . do ( new AMCP . ResumeCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#STOP>
     */ public stop ( channel , layer ? ) { return this . do ( new AMCP . StopCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#CG-ADD>
     */ public cgAdd ( channel , layer = NaN , flashLayer = NaN , templateName , playOnLoad , data ? ) { return this . do ( new AMCP . CGAddCommand ( { channel : channel , layer : layer , flashLayer : flashLayer , templateName : templateName , playOnLoad : playOnLoad , data : data } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#CG-PLAY>
     */ public cgPlay ( channel , layer ? , flashLayer ? ) { return this . do ( new AMCP . CGPlayCommand ( { channel : channel , layer : layer , flashLayer : flashLayer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#CG-STOP>
     */ public cgStop ( channel , layer ? , flashLayer ? ) { return this . do ( new AMCP . CGStopCommand ( { channel : channel , layer : layer , flashLayer : flashLayer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#CG-NEXT>
     */ public cgNext ( channel , layer ? , flashLayer ? ) { return this . do ( new AMCP . CGNextCommand ( { channel : channel , layer : layer , flashLayer : flashLayer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#CG-REMOVE>
     */ public cgRemove ( channel , layer ? , flashLayer ? ) { return this . do ( new AMCP . CGRemoveCommand ( { channel : channel , layer : layer , flashLayer : flashLayer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#CG-CLEAR>
     */ public cgClear ( channel , layer ? ) { return this . do ( new AMCP . CGClearCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#CG-UPDATE>
     */ public cgUpdate ( channel , layer = NaN , flashLayer , data ) { return this . do ( new AMCP . CGUpdateCommand ( { channel : channel , layer : layer , flashLayer : flashLayer , data : data } ) ) ; } public cgInvoke ( channel , layer , flashLayer , method ) { return this . do ( new AMCP . CGInvokeCommand ( { channel : channel , layer : layer , flashLayer : flashLayer , method : method } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-KEYER>
     */ public mixerKeyer ( channel , layer , state ? , defer ? ) ; public mixerKeyer ( channel , layer ? , state ? , defer ? ) { return this . do ( new AMCP . MixerKeyerCommand ( { channel : channel , layer : layer , keyer : state , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-KEYER>
     */ public mixerKeyerDeferred ( channel , layer , state ? ) { return this . mixerKeyer ( channel , layer , state , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-KEYER>
     */ public getMixerStatusKeyer ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusKeyerCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CHROMA>
     */ public mixerChroma ( channel , layer , keyer , threshold , softness , spill , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerChroma ( channel , layer , keyer , threshold , softness , spill , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerChroma ( channel , layer , keyer ? , threshold ? , softness ? , spill ? , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerChroma ( channel , layer = 0 , keyer ? , threshold ? , softness ? , spill ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerChromaCommand ( { channel : channel , layer : layer , keyer : keyer , threshold : threshold , softness : softness , spill : spill , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CHROMA>
     */ public mixerChromaDeferred ( channel , layer , keyer , threshold , softness , spill , transitionDuration ? , transitionEasing ? ) ; public mixerChromaDeferred ( channel , layer = 0 , keyer , threshold , softness , spill , transitionDuration ? , transitionEasing ? ) { return this . mixerChroma ( channel , layer , keyer , threshold , softness , spill , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CHROMA>
     */ public getMixerStatusChroma ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusChromaCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-BLEND>
     */ public mixerBlend ( channel , layer , blendmode , defer ? ) ; public mixerBlend ( channel , layer ? , blendmode ? , defer ? ) ; public mixerBlend ( channel , layer ? , blendmode ? , defer ? ) { return this . do ( new AMCP . MixerBlendCommand ( { channel : channel , layer : layer , blendmode : blendmode , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-BLEND>
     */ public mixerBlendDeferred ( channel , layer , blendmode ) ; public mixerBlendDeferred ( channel , layer = NaN , blendmode ) { return this . mixerBlend ( channel , layer , blendmode , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-BLEND>
     */ public getMixerStatusBlend ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusBlendCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-OPACITY>
     */ public mixerOpacity ( channel , layer , opacity , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerOpacity ( channel , layer ? , opacity ? , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerOpacity ( channel , layer ? , opacity ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerOpacityCommand ( { channel : channel , layer : layer , opacity : opacity , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-OPACITY>
     */ public mixerOpacityDeferred ( channel , layer = NaN , opacity , transitionDuration ? , transitionEasing ? ) { return this . mixerOpacity ( channel , layer , opacity , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-OPACITY>
     */ public getMixerStatusOpacity ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusOpacityCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-BRIGHTNESS>
     */ public mixerBrightness ( channel , layer , brightness , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerBrightness ( channel , layer ? , brightness ? , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerBrightness ( channel , layer ? , brightness ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerBrightnessCommand ( { channel : channel , layer : layer , brightness : brightness , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-BRIGHTNESS>
     */ public mixerBrightnessDeferred ( channel , layer = NaN , brightness , transitionDuration ? , transitionEasing ? ) { return this . mixerBrightness ( channel , layer , brightness , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-BRIGHTNESS>
     */ public getMixerStatusBrightness ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusBrightnessCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-SATURATION>
     */ public mixerSaturation ( channel , layer , saturation , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerSaturation ( channel , layer ? , saturation ? , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerSaturation ( channel , layer ? , saturation ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerSaturationCommand ( { channel : channel , layer : layer , saturation : saturation , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-SATURATION>
     */ public mixerSaturationDeferred ( channel , layer = NaN , saturation , transitionDuration ? , transitionEasing ? ) { return this . mixerSaturation ( channel , layer , saturation , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-SATURATION>
     */ public getMixerStatusSaturation ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusSaturationCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CONTRAST>
     */ public mixerContrast ( channel , layer , contrast , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerContrast ( channel , layer ? , contrast ? , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerContrast ( channel , layer ? , contrast ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerContrastCommand ( { channel : channel , layer : layer , contrast : contrast , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CONTRAST>
     */ public mixerContrastDeferred ( channel , layer = NaN , contrast , transitionDuration ? , transitionEasing ? ) { return this . mixerContrast ( channel , layer , contrast , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CONTRAST>
     */ public getMixerStatusContrast ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusContrastCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-LEVELS>
     */ public mixerLevels ( channel , layer , minInput , maxInput , gamma , minOutput , maxOutput , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerLevels ( channel , layer , minInput , maxInput , gamma , minOutput , maxOutput , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerLevels ( channel , layer = NaN , minInput ? , maxInput ? , gamma ? , minOutput ? , maxOutput ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerLevelsCommand ( { channel : channel , layer : layer , minInput : minInput , maxInput : maxInput , gamma : gamma , minOutput : minOutput , maxOutput : maxOutput , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-LEVELS>
     */ public mixerLevelsDeferred ( channel , layer = NaN , minInput , maxInput , gamma , minOutput , maxOutput , transitionDuration ? , transitionEasing ? ) { return this . mixerLevels ( channel , layer , minInput , maxInput , gamma , minOutput , maxOutput , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-LEVELS>
     */ public getMixerStatusLevels ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusLevelsCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-FILL>
     */ public mixerFill ( channel , layer , x , y , xScale , yScale , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerFill ( channel , layer , x , y , xScale , yScale , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerFill ( channel , layer = NaN , x ? , y ? , xScale ? , yScale ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerFillCommand ( { channel : channel , layer : layer , x : x , y : y , xScale : xScale , yScale : yScale , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } public mixerFillDeferred ( channel , layer = NaN , x , y , xScale , yScale , transitionDuration ? , transitionEasing ? ) { return this . mixerFill ( channel , layer , x , y , xScale , yScale , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-FILL>
     */ public getMixerStatusFill ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusFillCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CLIP>
     */ public mixerClip ( channel , layer , x , y , width , height , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerClip ( channel , layer , x , y , width , height , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerClip ( channel , layer = NaN , x ? , y ? , width ? , height ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerClipCommand ( { channel : channel , layer : layer , x : x , y : y , width : width , height : height , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CLIP>
     */ public mixerClipDeferred ( channel , layer = NaN , x , y , width , height , transitionDuration ? , transitionEasing ? ) { return this . mixerClip ( channel , layer , x , y , width , height , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CLIP>
     */ public getMixerStatusClip ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusClipCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-ANCHOR>
     */ public mixerAnchor ( channel , layer , x , y , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerAnchor ( channel , layer , x , y , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerAnchor ( channel , layer = NaN , x ? , y ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerAnchorCommand ( { channel : channel , layer : layer , x : x , y : y , ransition : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-ANCHOR>
     */ public mixerAnchorDeferred ( channel , layer = NaN , x , y , transitionDuration ? , transitionEasing ? ) { return this . mixerAnchor ( channel , layer , x , y , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-ANCHOR>
     */ public getMixerStatusAnchor ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusAnchorCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CROP>
     */ public mixerCrop ( channel , layer , left , top , right , bottom , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerCrop ( channel , layer , left , top , right , bottom , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerCrop ( channel , layer = NaN , left ? , top ? , right ? , bottom ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerCropCommand ( { channel : channel , layer : layer , left : left , top : top , right : right , bottom : bottom , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CROP>
     */ public mixerCropDeferred ( channel , layer = NaN , left , top , right , bottom , transitionDuration ? , transitionEasing ? ) { return this . mixerCrop ( channel , layer , left , top , right , bottom , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CROP>
     */ public getMixerStatusCrop ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusCropCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-ROTATION>
     */ public mixerRotation ( channel , layer , rotation , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerRotation ( channel , layer ? , rotation ? , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerRotation ( channel , layer ? , rotation ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerRotationCommand ( { channel : channel , layer : layer , rotation : rotation , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-ROTATION>
     */ public mixerRotationDeferred ( channel , layer = NaN , rotation , transitionDuration ? , transitionEasing ? ) { return this . mixerRotation ( channel , layer , rotation , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-ROTATION>
     */ public getMixerStatusRotation ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusRotationCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-PERSPECTIVE>
     */ public mixerPerspective ( channel , layer , topLeftX , topLeftY , topRightX , topRightY , bottomRightX , bottomRightY , bottomLeftX , bottomLeftY , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerPerspective ( channel , layer , topLeftX , topLeftY , topRightX , topRightY , bottomRightX , bottomRightY , bottomLeftX , bottomLeftY , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerPerspective ( channel , layer = NaN , topLeftX ? , topLeftY ? , topRightX ? , topRightY ? , bottomRightX ? , bottomRightY ? , bottomLeftX ? , bottomLeftY ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerPerspectiveCommand ( { channel : channel , layer : layer , topLeftX : topLeftX , topLeftY : topLeftY , topRightX : topRightX , topRightY : topRightY , bottomRightX : bottomRightX , bottomRightY : bottomRightY , bottomLeftX : bottomLeftX , bottomLeftY : bottomLeftY , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-PERSPECTIVE>
     */ public mixerPerspectiveDeferred ( channel , layer = NaN , topLeftX , topLeftY , topRightX , topRightY , bottomRightX , bottomRightY , bottomLeftX , bottomLeftY , transitionDuration ? , transitionEasing ? ) { return this . mixerPerspective ( channel , layer , topLeftX , topLeftY , topRightX , topRightY , bottomRightX , bottomRightY , bottomLeftX , bottomLeftY , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-PERSPECTIVE>
     */ public getMixerStatusPerspective ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusPerspectiveCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-MIPMAP>
     */ public mixerMipmap ( channel , layer ? , state ? , defer ? ) ; public mixerMipmap ( channel , layer ? , state ? , defer ? ) { return this . do ( new AMCP . MixerMipmapCommand ( { channel : channel , layer : layer , keyer : state , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-MIPMAP>
     */ public mixerMipmapDeferred ( channel , layer ? , state ? ) { return this . mixerMipmap ( channel , layer , state , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-MIPMAP>
     */ public getMixerStatusMipmap ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusMipmapCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-VOLUME>
     */ public mixerVolume ( channel , layer , volume , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerVolume ( channel , layer ? , volume ? , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerVolume ( channel , layer ? , volume ? , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerVolumeCommand ( { channel : channel , layer : layer , volume : volume , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-VOLUME>
     */ public mixerVolumeDeferred ( channel , layer = NaN , volume , transitionDuration ? , transitionEasing ? ) { return this . mixerVolume ( channel , layer , volume , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-VOLUME>
     */ public getMixerStatusVolume ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusVolumeCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-MASTERVOLUME>
     */ public mixerMastervolume ( channel , mastervolume ? , defer ? ) ; public mixerMastervolume ( channel , mastervolume ? , defer ? ) { return this . do ( new AMCP . MixerMastervolumeCommand ( { channel : channel , mastervolume : mastervolume , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-MASTERVOLUME>
     */ public mixerMastervolumeDeferred ( channel , mastervolume ? ) { return this . mixerMastervolume ( channel , mastervolume , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-MASTERVOLUME>
     */ public getMixerStatusMastervolume ( channel ) { return this . do ( new AMCP . MixerStatusMastervolumeCommand ( { channel : channel } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-STRAIGHT_ALPHA_OUTPUT>
     */ public mixerStraightAlphaOutput ( channel , layer ? , state ? , defer ? ) ; public mixerStraightAlphaOutput ( channel , layer ? , state ? , defer ? ) { return this . do ( new AMCP . MixerKeyerCommand ( { channel : channel , layer : layer , keyer : state , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-STRAIGHT_ALPHA_OUTPUT>
     */ public mixerStraightAlphaOutputDeferred ( channel , layer ? , state ? ) { return this . mixerStraightAlphaOutput ( channel , layer , state , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-STRAIGHT_ALPHA_OUTPUT>
     */ public getMixerStatusStraightAlphaOutput ( channel , layer ? ) { return this . do ( new AMCP . MixerStatusStraightAlphaOutputCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-GRID>
     */ public mixerGrid ( channel , resolution , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerGrid ( channel , resolution , transitionDuration ? , transitionEasing ? , defer ? ) ; public mixerGrid ( channel , resolution , transitionDuration ? , transitionEasing ? , defer ? ) { return this . do ( new AMCP . MixerGridCommand ( { channel : channel , resolution : resolution , transitionDuration : transitionDuration , transitionEasing : transitionEasing , defer : defer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-GRID>
     */ public mixerGridDeferred ( channel , resolution , transitionDuration ? , transitionEasing ? ) { return this . mixerGrid ( channel , resolution , transitionDuration , transitionEasing , true ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-COMMIT>
     */ public mixerCommit ( channel ) { return this . do ( new AMCP . MixerCommitCommand ( { channel : channel } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#MIXER-CLEAR>
     */ public mixerClear ( channel , layer ? ) { return this . do ( new AMCP . MixerClearCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#CLEAR>
     */ public clear ( channel , layer ? ) { return this . do ( new AMCP . ClearCommand ( { channel : channel , layer : layer } ) ) ; } todo todo public call ( channel , layer ? ) { return this . do ( new AMCP . CallCommand ( { channel : channel , layer : layer } ) ) ; } todo todo public swap ( ) { return this . do ( new AMCP . SwapCommand ( ) ) ; } todo todo public add ( channel ) { return this . do ( new AMCP . AddCommand ( { channel : channel } ) ) ; } /**
     *  <https://github.com/CasparCG/help/wiki/AMCP-Protocol#ADD>
     */ public addDecklink ( channel , device , id ? ) { return this . do ( new AMCP . AddDecklinkCommand ( { channel : channel , layer : id , device : device } ) ) ; } /**
     *  <https://github.com/CasparCG/help/wiki/AMCP-Protocol#ADD>
     */ public addImage ( channel , fileName , id ? ) { return this . do ( new AMCP . AddImageCommand ( { channel : channel , layer : id , fileName : fileName } ) ) ; } /**
     *  <https://github.com/CasparCG/help/wiki/AMCP-Protocol#ADD>
     */ public addFile ( channel , fileName , id ? ) { return this . do ( new AMCP . AddFileCommand ( { channel : channel , layer : id , fileName : fileName } ) ) ; } /**
     *  <https://github.com/CasparCG/help/wiki/AMCP-Protocol#ADD>
     */ public addStream ( channel , uri , params , id ? ) { return this . do ( new AMCP . AddStreamCommand ( { channel : channel , layer : id , uri : uri , params : params } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#REMOVE>
     */ public remove ( channel , id ) { return this . do ( new AMCP . RemoveCommand ( { channel : channel , layer : id } ) ) ; } /**
     *  <https://github.com/CasparCG/help/wiki/AMCP-Protocol#REMOVE>
     */ public removeDecklink ( channel , device ) { return this . do ( new AMCP . RemoveDecklinkCommand ( { channel : channel , device : device } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#REMOVE>
     */ public removeImage ( channel , fileName ) { return this . do ( new AMCP . RemoveImageCommand ( { channel : channel , fileName : fileName } ) ) ; } /**
     *  <https://github.com/CasparCG/help/wiki/AMCP-Protocol#REMOVE>
     */ public removeFile ( channel , fileName ) { return this . do ( new AMCP . RemoveFileCommand ( { channel : channel , fileName : fileName } ) ) ; } /**
     *  <https://github.com/CasparCG/help/wiki/AMCP-Protocol#REMOVE>
     */ public removeStream ( channel , uri ) { return this . do ( new AMCP . RemoveStreamCommand ( { channel : channel , uri : uri } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#PRINT>
     */ public print ( channel ) { return this . do ( new AMCP . PrintCommand ( { channel : channel } ) ) ; } todo todo public set ( channel ) { return this . do ( new AMCP . SetCommand ( { channel : channel } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOCK>
     */ public lock ( channel , action , lockPhrase ? ) ; public lock ( channel , action , lockPhrase ? ) { return this . do ( new AMCP . LockCommand ( { channel : channel , action : action , phrase : lockPhrase } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#CHANNEL-GRID>
     */ public channelGrid ( ) { return this . do ( new AMCP . ChannelGridCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#GL-GC>
     */ public glGC ( ) { return this . do ( new AMCP . GlGCCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#DATA-STORE>
     */ public dataStore ( fileName , data ) { return this . do ( new AMCP . DataStoreCommand ( { fileName : fileName , data : data } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#DATA-RETRIEVE>
     */ public dataRetrieve ( fileName ) { return this . do ( new AMCP . DataRetrieveCommand ( { fileName : fileName } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#DATA-LIST>
     */ public dataList ( ) { return this . do ( new AMCP . DataListCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#DATA-REMOVE>
     */ public dataRemove ( fileName ) { return this . do ( new AMCP . DataRemoveCommand ( { fileName : fileName } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#THUMBNAIL-LIST>
     */ public thumbnailList ( subFolder ? ) { return this . do ( new AMCP . ThumbnailListCommand ( { subFolder : subFolder } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#THUMBNAIL-RETRIEVE>
     */ public thumbnailRetrieve ( fileName ) { return this . do ( new AMCP . ThumbnailRetrieveCommand ( { fileName : fileName } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#THUMBNAIL-GENERATE>
     */ public thumbnailGenerate ( fileName ) { return this . do ( new AMCP . ThumbnailGenerateCommand ( { fileName : fileName } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#THUMBNAIL-GENERATE_ALL>
     */ public thumbnailGenerateAll ( ) { return this . do ( new AMCP . ThumbnailGenerateAllCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#CINF>
     */ public cinf ( fileName ) { return this . do ( new AMCP . CinfCommand ( { fileName : fileName } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#CLS>
     */ public cls ( subFolder ? ) { return this . do ( new AMCP . ClsCommand ( { subFolder : subFolder } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#FLS>
     */ public fls ( ) { return this . do ( new AMCP . FlsCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#TLS>
     */ public tls ( subFolder ? ) { return this . do ( new AMCP . TlsCommand ( { subFolder : subFolder } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#VERSION>
     */ public version ( component ? ) { return this . do ( new AMCP . VersionCommand ( { component : component } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#INFO>
     */ public info ( channel ? , layer ? ) { return this . do ( new AMCP . InfoCommand ( { channel : channel , layer : layer } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#INFO-TEMPLATE>
     */ public infoTemplate ( template ) { return this . do ( new AMCP . InfoTemplateCommand ( { template : template } ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#INFO-CONFIG>
     */ public infoConfig ( ) { return new Promise < IAMCPCommand > ( ( resolve , reject ) => { this . getCasparCGVersion ( ) . then ( ( version ) => { resolve ( this . do ( new AMCP . InfoConfigCommand ( [ ] , { serverVersion : version } ) ) ) ; } ) . catch ( reject ) ; } ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#INFO-PATHS>
     */ public infoPaths ( ) { return this . do ( new AMCP . InfoPathsCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#INFO-SYSTEM>
     */ public infoSystem ( ) { return this . do ( new AMCP . InfoSystemCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#INFO-SERVER>
     */ public infoServer ( ) { return this . do ( new AMCP . InfoServerCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#INFO-QUEUES>
     */ public infoQueues ( ) { return this . do ( new AMCP . InfoQueuesCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#INFO-THREADS>
     */ public infoThreads ( ) { return this . do ( new AMCP . InfoThreadsCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#INFO-DELAY>
     */ public infoDelay ( channel , layer ? ) { return this . do ( new AMCP . InfoDelayCommand ( { channel : channel , layer : layer } ) ) ; } param flashLayer public cgInfo ( channel , layer ? , flashLayer ? ) { return this . do ( new AMCP . CGInfoCommand ( { channel : channel , layer : layer , flashLayer : flashLayer } ) ) ; } /**
     * Convenience method for calling [[cgInfo]] to return information about `TemplateHost` for a given layer.
     *
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#CG-INFO>
     */ public templateHostInfo ( channel , layer ? ) { return this . cgInfo ( channel , layer ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#GL-INFO>
     */ public glInfo ( ) { return this . do ( new AMCP . GlInfoCommand ( ) ) ; } /**
     * Sets the server's [[LogLevel]].
     *
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOG-LEVEL>
     */ public logLevel ( enumOrString ) { return this . do ( new AMCP . LogLevelCommand ( { level : enumOrString } ) ) ; } /**
     * Enabling or disabling logging for a given [[LogCategory]].
     *
     * Convenience methods [[logCalltrace]] and [[logCommunication]] are available.
     *
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#LOG_CATEGORY>
     */ public logCategory ( category , enabled ) { let params = { } ; params [ category . toString ( ) . toLowerCase ( ) ] = enabled ; return this . do ( new AMCP . LogCategoryCommand ( params ) ) ; } /**
     * Convenience method for enabling or disabling logging for [[LogCategory.CALLTRACE]] through calling [[logCategory]].
     */ public logCalltrace ( enabled ) { return this . logCategory ( Enum . LogCategory . CALLTRACE , enabled ) ; } /**
     * Convenience method for enabling or disabling logging for [[LogCategory.COMMUNICATION]] through calling [[logCategory]].
     */ public logCommunication ( enabled ) { return this . logCategory ( Enum . LogCategory . COMMUNICATION , enabled ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#DIAG>
     */ public diag ( ) { return this . do ( new AMCP . DiagCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#HELP>
     */ public help ( ) ; public help ( commandOrName ? ) { let param = { } ; if ( commandOrName ) { param [ 'command' ] = commandOrName ; } return this . do ( new AMCP . HelpCommand ( param ) ) ; } /**
     * Convenience method for calling [[help]] with no parameters.
     *
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#HELP>
     */ public getCommands ( ) { return this . help ( ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#HELP-PRODUCER>
     */ public helpProducer ( ) ; public helpProducer ( producerOrName ? ) { let param = { } ; if ( producerOrName ) { param [ 'producer' ] = producerOrName ; } return this . do ( new AMCP . HelpProducerCommand ( param ) ) ; } /**
     * Convenience method for calling [[helpProducer]] with no parameters.
     *
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#HELP-PRODUCER>
     */ public getProducers ( ) { return this . helpProducer ( ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#HELP-CONSUMER>
     */ public helpConsumer ( consumerOrName ? ) { let param = { } ; if ( consumerOrName ) { param [ 'consumer' ] = consumerOrName ; } return this . do ( new AMCP . HelpConsumerCommand ( param ) ) ; } /**
     * Convenience method for calling [[helpConsumer]] with no parameters.
     *
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#HELP-CONSUMER>
     */ public getConsumers ( ) { return this . helpConsumer ( ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#BYE>
     */ public bye ( ) { return this . do ( new AMCP . ByeCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#KILL>
     */ public kill ( ) { return this . do ( new AMCP . KillCommand ( ) ) ; } /**
     * <https://github.com/CasparCG/help/wiki/AMCP-Protocol#RESTART>
     */ public restart ( ) { return this . do ( new AMCP . RestartCommand ( ) ) ; } /**
     * Undocumented, but implemented by Julusian.
     */ public ping ( ) { return this . do ( new AMCP . PingCommand ( ) ) ; } /**
     * Undocumented, but implemented by Julusian.
     */ public time ( channel , timecode ? ) { return this . do ( new AMCP . TimeCommand ( { channel , timecode } ) ) ; } /**
     * https://github.com/CasparCG/server/issues/872
     */ public scheduleSet ( timecode , command ) { return this . do ( new AMCP . ScheduleSetCommand ( { token : command . token , timecode , command } ) ) ; } /**
     * https://github.com/CasparCG/server/issues/872
     */ public scheduleRemove ( token ) { return this . do ( new AMCP . ScheduleRemoveCommand ( { token } ) ) ; } /**
     * https://github.com/CasparCG/server/issues/872
     */ public scheduleClear ( ) { return this . do ( new AMCP . ScheduleClearCommand ( ) ) ; } /**
     * https://github.com/CasparCG/server/issues/872
     */ public scheduleList ( timecode ? ) { return this . do ( new AMCP . ScheduleListCommand ( { timecode } ) ) ; } /**
     * Automatically create a transition object with the correct transition keys
     */ private _createTransitionOptionsObject ( transition ? , transitionDurationOrMaskFileOrProps ? , transitionEasingOrStingDuration ? , transitionDirectionOrOverlay ? ) { if ( transition === Enum . Transition . STING . toString ( ) ) { if ( typeof transitionDurationOrMaskFileOrProps === 'object' ) { return { stingTransitionProperties : { ... transitionDurationOrMaskFileOrProps } } ; } else { return { stingMaskFilename : transitionDurationOrMaskFileOrProps , stingDelay : transitionEasingOrStingDuration , stingOverlayFilename : transitionDirectionOrOverlay || '' } ; } } else { return { transitionDuration : transitionDurationOrMaskFileOrProps , transitionEasing : transitionEasingOrStingDuration , transitionDirection : transitionDirectionOrOverlay } ; } } /**
     *
     */ private _createNewSocket ( options ? , enforceRecreation = false ) { let hasNewOptions = false ; if ( options ) { for ( let key in options ) { if ( ! options . hasOwnProperty ( key ) ) { continue ; } if ( this . hasOwnProperty ( key ) || CasparCG . prototype . hasOwnProperty ( key ) ) { if ( ( this as any ) [ key ] !== ( options as any ) [ key ] ) { ( this as any ) [ key ] = ( options as any ) [ key ] ; hasNewOptions = true ; } } } } if ( this . _socket && ( this . _socket . host !== this . host ) ) { hasNewOptions = true ; } if ( this . _socket && ( this . _socket . port !== this . port ) ) { hasNewOptions = true ; } if ( this . _socket && ! hasNewOptions && ! enforceRecreation ) { return ; } if ( this . _socket ) { this . _socket . dispose ( ) ; delete this . _socket ; } this . _socket = new CasparCGSocket ( this . host , this . port , this . autoReconnect , this . autoReconnectInterval , this . autoReconnectAttempts , this . queueMode ) ; this . _socket . on ( 'error' , ( error ) => this . _onSocketError ( error ) ) ; this . _socket . on ( CasparCGSocketStatusEvent . STATUS , ( event ) => this . _onSocketStatusChange ( event ) ) ; this . _socket . on ( CasparCGSocketStatusEvent . TIMEOUT , ( ) => this . _onSocketStatusTimeout ( ) ) ; this . _socket . on ( CasparCGSocketResponseEvent . RESPONSE , ( event ) => this . _handleSocketResponse ( event . response ) ) ; this . _socket . on ( CasparCGSocketResponseEvent . INVALID_RESPONSE , ( ) => this . _handleInvalidSocketResponse ( ) ) ; this . _socket . log = ( args ) => this . _log ( args ) ; } /**
     *
     */ private _fetchNextCommand ( ) { let VO = null ; if ( this . _queuedCommandsHighPriority . length > 0 ) { VO = { cmd : this . _queuedCommandsHighPriority . shift ( ) ! , priority : Priority . HIGH } ; } else if ( this . _queuedCommands . length > 0 ) { VO = { cmd : this . _queuedCommands . shift ( ) ! , priority : Priority . NORMAL } ; } else if ( this . _queuedCommandsLowPriority . length > 0 ) { VO = { cmd : this . _queuedCommandsLowPriority . shift ( ) ! , priority : Priority . LOW } ; } return VO ; } /**
     *
     */ private get _nextCommand ( ) : { cmd : IAMCPCommand ; priority : Priority ; } | null { if ( this . _queuedCommandsHighPriority . length > 0 ) { return { cmd : this . _queuedCommandsHighPriority [ 0 ] , priority : Priority . HIGH } ; } else if ( this . _queuedCommands . length > 0 ) { return { cmd : this . _queuedCommands [ 0 ] , priority : Priority . NORMAL } ; } else if ( this . _queuedCommandsLowPriority . length > 0 ) { return { cmd : this . _queuedCommandsLowPriority [ 0 ] , priority : Priority . LOW } ; } else { return null ; } } /**
     *
     */ private _onSocketError ( error ) { this . _log ( error ) ; } /**
     *
     */ private _log ( args ) { if ( args instanceof Error ) { if ( this . listenerCount ( 'error' ) > 0 ) { this . emit ( 'error' , args ) ; } if ( this . onError ) { this . onError ( args ) ; } } else { if ( this . debug ) { console . log ( args ) ; } if ( this . onLog ) { this . onLog ( args ) ; } this . emit ( LogEvent . LOG , new LogEvent ( args ) ) ; } } /**
     *
     */ private _onSocketStatusChange ( socketStatus ) { let connected = socketStatus . valueOf ( ) . connected === true ; if ( this . onConnectionStatus ) { this . onConnectionStatus ( socketStatus . valueOf ( ) ) ; } if ( connected !== this . _connected ) { if ( connected ) { this . _flushSentCommands ( ) ; delete this . _configPromise ; delete this . _pathsPromise ; delete this . _versionPromise ; } this . _connected = connected ; this . emit ( CasparCGSocketStatusEvent . STATUS_CHANGED , socketStatus ) ; if ( this . onConnectionChanged ) { this . onConnectionChanged ( this . _connected ) ; } if ( this . _connected ) { this . _executeNextCommand ( ) ; if ( this . virginServerCheck ) { this . doNow ( new AMCP . InfoCommand ( ) ) . then ( ( info ) => { let channelPromises = [ ] ; let channelLength = info . response . data . length ; for ( let i = 1 ; i <= channelLength ; i ++ ) { channelPromises . push ( this . doNow ( new AMCP . InfoCommand ( { channel : i } ) ) ) ; } let virgin = true ; return Promise . all ( channelPromises ) . then ( ( channels ) => { for ( let i = 0 ; i < channels . length ; i ++ ) { let channelInfo = channels [ i ] ; if ( channelInfo . response . data . stage ) { virgin = false ; break ; } } this . emit ( CasparCGSocketStatusEvent . CONNECTED , { connected : this . _connected , virginServer : virgin } ) ; if ( this . onConnected ) { this . onConnected ( this . _connected ) ; } } ) ; } ) . catch ( ( ) => { this . emit ( CasparCGSocketStatusEvent . CONNECTED , socketStatus ) ; if ( this . onConnected ) { this . onConnected ( this . _connected ) ; } } ) ; } else { this . emit ( CasparCGSocketStatusEvent . CONNECTED , socketStatus ) ; if ( this . onConnected ) { this . onConnected ( this . _connected ) ; } } } if ( ! this . _connected ) { this . emit ( CasparCGSocketStatusEvent . DISCONNECTED , socketStatus ) ; if ( this . onDisconnected ) { this . onDisconnected ( this . _connected ) ; } } } } /**
     *
     */ private _onSocketStatusTimeout ( ) { if ( Object . keys ( this . _sentCommands ) . length > 0 ) { this . _log ( `Command timed out. Starting flush procedure, with ${ Object . keys ( this . _sentCommands ) . length } command(s) in sentCommands.` ) ; } this . reconnect ( ) ; } /**
     *
     */ private _handleSocketResponse ( socketResponse ) { let currentCommand ; if ( socketResponse . token ) { if ( this . _queueMode === QueueMode . SALVO && ! this . _sentCommands [ socketResponse . token ] ) { this . _log ( `Received a response from an unknown command with token ${ socketResponse . token }` ) ; return ; } currentCommand = this . _sentCommands [ socketResponse . token ] ; delete this . _sentCommands [ socketResponse . token ] ; } else { if ( Object . keys ( this . _sentCommands ) . length === 0 ) { this . _log ( `Received a response without knowlingy having sent anyting.` ) ; return ; } let token = Object . keys ( this . _sentCommands ) [ 0 ] ; currentCommand = ( this . _sentCommands [ token ] ) ; delete this . _sentCommands [ token ] ; } this . _log ( `Handling response, "${ currentCommand . name }" with token "${ currentCommand . token }"` ) ; if ( ! ( currentCommand . response instanceof AMCPResponse ) ) { currentCommand . response = new AMCPResponse ( ) ; } if ( currentCommand . validateResponse ( socketResponse ) ) { if ( currentCommand . name === 'ScheduleSetCommand' ) { let scheduledCommand = currentCommand . getParam ( 'command' ) as IAMCPCommand ; scheduledCommand . status = IAMCPStatus . Sent ; this . _sentCommands [ scheduledCommand . token ] = scheduledCommand ; this . _log ( `New command scheduled, "${ scheduledCommand . name }".` ) ; } else if ( currentCommand . name === 'ScheduleRemoveCommand' ) { delete this . _sentCommands [ currentCommand . getParam ( 'token' ) as string ] ; } currentCommand . status = IAMCPStatus . Suceeded ; currentCommand . resolve ( currentCommand ) ; } else { currentCommand . status = IAMCPStatus . Failed ; currentCommand . reject ( currentCommand ) ; } this . emit ( CasparCGSocketCommandEvent . RESPONSE , new CasparCGSocketCommandEvent ( currentCommand ) ) ; this . _executeNextCommand ( ) ; } /**
     *
     */ private _handleInvalidSocketResponse ( ) { } /**
     *
     */ private _flushSentCommands ( ) { for ( let token in this . _sentCommands ) { let i = this . _sentCommands [ token ] ; delete this . _sentCommands [ token ] ; this . _log ( `Flushing commands from sent-queue. Deleting: "${ i . name }" with token "${ i . token }".` ) ; i . status = IAMCPStatus . Failed ; i . reject ( i ) ; } } /**
     *
     */ private _executeNextCommand ( ) { if ( this . connected ) { if ( this . _queueMode === QueueMode . SALVO ) { while ( this . commandQueueLength > 0 ) { let nextCommand = this . _fetchNextCommand ( ) ; if ( nextCommand ) { this . _sentCommands [ nextCommand . cmd . token ] = nextCommand . cmd ; this . _log ( `Sending command, "${ nextCommand . cmd . name }" with priority "${ nextCommand . priority === 1 ? 'NORMAL' : nextCommand . priority === 2 ? 'HIGH' : nextCommand . priority === 0 ? 'LOW' : 'unknown' }". ${ this . _sentCommands . length } command(s) in sentCommands, ${ this . commandQueueLength } command(s) in command queues.` ) ; this . _socket . executeCommand ( nextCommand . cmd ) ; } } } else if ( this . _queueMode === QueueMode . SEQUENTIAL ) { let nextCommand = this . _fetchNextCommand ( ) ; if ( nextCommand ) { this . _sentCommands [ nextCommand . cmd . token ] = nextCommand . cmd ; this . _log ( `Sending command, "${ nextCommand . cmd . name }" with priority "${ nextCommand . priority === 1 ? 'NORMAL' : nextCommand . priority === 2 ? 'HIGH' : nextCommand . priority === 0 ? 'LOW' : 'unknown' }". ${ this . _sentCommands . length } command(s) in sentCommands, ${ this . commandQueueLength } command(s) in command queues.` ) ; this . _socket . executeCommand ( nextCommand . cmd ) ; } } } else { if ( this . commandQueueLength > 0 ) { this . _log ( `Can't process commands, socket not connected. ${ this . commandQueueLength } commands left in commandsQueue, the first one being "${ this . _nextCommand ? this . _nextCommand . cmd . name : 'null' }".` ) ; } } } }