From 8c3832006235d3549f3a19a02f7104f05d3ad557 Mon Sep 17 00:00:00 2001 From: Baud Date: Fri, 31 May 2024 00:28:41 +0100 Subject: [PATCH] _hisses in exasperation_ --- index.ts | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/index.ts b/index.ts index 80918a4..8fb2f38 100644 --- a/index.ts +++ b/index.ts @@ -90,23 +90,29 @@ function handle_message(message: Partial) { hyperdeckId: message.id, state: transportInfo.status, }) - }) - }) + }).catch(() => {}) + }, 1000) - newHyperdeck.sendCommand(new Commands.DeviceInfoCommand()).then((info) => { - for (let index = 0; index < info.slots; index++) { - setInterval(() => { - newHyperdeck.sendCommand(new Commands.SlotInfoCommand(index)).then((slot) => { - notifyClients({ - event: "record_time_remaining", - hyperdeckId: message.id, - slotId: slot.slotId, - remaining: slot.recordingTime - }) - }) + let connected = false; + while (!connected) { + try { + newHyperdeck.sendCommand(new Commands.DeviceInfoCommand()).then((info) => { + for (let index = 0; index < info.slots; index++) { + setInterval(() => { + newHyperdeck.sendCommand(new Commands.SlotInfoCommand(index)).then((slot) => { + notifyClients({ + event: "record_time_remaining", + hyperdeckId: message.id, + slotId: slot.slotId, + remaining: slot.recordingTime + }) + }).catch(() => {}) + }, 1000) + connected = true; + } }) - } - }) + } catch (_err) {} + } }) newHyperdeck.on('notify.slot', function (slot) {