(payload: { machineId: string; time: number })
| 109 | } |
| 110 | |
| 111 | handleMachineAlive(payload: { machineId: string; time: number }): void { |
| 112 | const t = clampAliveTime(payload.time) |
| 113 | if (!t) return |
| 114 | |
| 115 | const machine = this.machines.get(payload.machineId) ?? this.refreshMachine(payload.machineId) |
| 116 | if (!machine) return |
| 117 | |
| 118 | const wasActive = machine.active |
| 119 | machine.active = true |
| 120 | machine.activeAt = Math.max(machine.activeAt, t) |
| 121 | |
| 122 | const now = Date.now() |
| 123 | const lastBroadcastAt = this.lastBroadcastAtByMachineId.get(machine.id) ?? 0 |
| 124 | const shouldBroadcast = (!wasActive && machine.active) || (now - lastBroadcastAt > 10_000) |
| 125 | if (shouldBroadcast) { |
| 126 | this.lastBroadcastAtByMachineId.set(machine.id, now) |
| 127 | this.publisher.emit({ type: 'machine-updated', machineId: machine.id, data: machine }) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | expireInactive(now: number = Date.now()): void { |
| 132 | const machineTimeoutMs = 45_000 |
nothing calls this directly
no test coverage detected