Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dcaputo-harmoni authored and thgreasi committed May 24, 2023
1 parent 38d9cf3 commit 58b655a
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions src/features/device-heartbeat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,30 +298,32 @@ export class DeviceOnlineStateManager extends EventEmitter<{
};

// raise and event for the state change...
switch (nextState) {
case DeviceOnlineStates.Timeout:
await this.updateDeviceModel(
deviceId,
DeviceOnlineStates.Timeout,
);
this.scheduleChangeOfStateForDevice(
deviceId,
await this.getDeviceOnlineState(deviceId),
DeviceOnlineStates.Timeout,
DeviceOnlineStates.Offline,
API_HEARTBEAT_STATE_TIMEOUT_SECONDS, // put the device into a timeout state if it misses it's scheduled heartbeat window... then mark as offline
);
break;
case DeviceOnlineStates.Offline:
await this.updateDeviceModel(
deviceId,
DeviceOnlineStates.Offline,
);
break;
default:
throw new Error(
`An unexpected value was encountered for the target device state: ${nextState}`,
);
if (deviceId) {
switch (nextState) {
case DeviceOnlineStates.Timeout:
await this.updateDeviceModel(
deviceId,
DeviceOnlineStates.Timeout,
);
this.scheduleChangeOfStateForDevice(
deviceId,
await this.getDeviceOnlineState(deviceId),
DeviceOnlineStates.Timeout,
DeviceOnlineStates.Offline,
API_HEARTBEAT_STATE_TIMEOUT_SECONDS, // put the device into a timeout state if it misses it's scheduled heartbeat window... then mark as offline
);
break;
case DeviceOnlineStates.Offline:
await this.updateDeviceModel(
deviceId,
DeviceOnlineStates.Offline,
);
break;
default:
throw new Error(
`An unexpected value was encountered for the target device state: ${nextState}`,
);
}
}

await this.rsmq.deleteMessageAsync({
Expand Down

0 comments on commit 58b655a

Please sign in to comment.