diff --git a/src/atem.ts b/src/atem.ts index 5294508a4..9fee13ea8 100644 --- a/src/atem.ts +++ b/src/atem.ts @@ -177,7 +177,7 @@ export class BasicAtem extends EventEmitter { private _mutateState(commands: IDeserializedCommand[]): void { // Is this the start of a new connection? - if (commands.find((cmd) => cmd.constructor.name === Commands.VersionCommand.name)) { + if (commands.find((cmd) => cmd instanceof Commands.VersionCommand)) { // On start of connection, create a new state object this._state = AtemStateUtil.Create() this._status = AtemConnectionStatus.CONNECTING @@ -238,7 +238,7 @@ export class BasicAtem extends EventEmitter { } } - const initComplete = commands.find((cmd) => cmd.constructor.name === Commands.InitCompleteCommand.name) + const initComplete = commands.find((cmd) => cmd instanceof Commands.InitCompleteCommand) if (initComplete) { this._status = AtemConnectionStatus.CONNECTED this._onInitComplete() diff --git a/src/lib/atemSocket.ts b/src/lib/atemSocket.ts index b63204a81..3d8a3e9cf 100644 --- a/src/lib/atemSocket.ts +++ b/src/lib/atemSocket.ts @@ -195,10 +195,9 @@ export class AtemSocket extends EventEmitter { this._commandParser.version ) - if (cmdConstructor.name === VersionCommand.name) { + if (cmd instanceof VersionCommand) { // init started - const verCmd = cmd as VersionCommand - this._commandParser.version = verCmd.properties.version + this._commandParser.version = cmd.properties.version } parsedCommands.push(cmd)