Skip to content

Commit

Permalink
fix: create new state object on connection start
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Dec 4, 2019
1 parent 5a8bac2 commit c9bac04
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/atem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export const DEFAULT_PORT = 9910

export class Atem extends EventEmitter {
private readonly socket: AtemSocket
private readonly _state: AtemState
private readonly dataTransferManager: DT.DataTransferManager
private readonly _log: (...args: any[]) => void
private _state: AtemState
private _sentQueue: {[packetId: string]: SentCommand } = {}

public on!: ((event: 'error', listener: (message: any) => void) => this) &
Expand Down Expand Up @@ -465,6 +465,11 @@ export class Atem extends EventEmitter {
}

private _mutateState (command: IDeserializedCommand) {
if (command.constructor.name === 'VersionCommand') {
// On start of connection, create a new state object
this._state = new AtemState()
}

let changePaths = command.applyToState(this.state)
if (!Array.isArray(changePaths)) {
changePaths = [ changePaths ]
Expand Down

0 comments on commit c9bac04

Please sign in to comment.