Skip to content

Commit

Permalink
Fix notification events order (#964)
Browse files Browse the repository at this point in the history
Apple backend processes events in reverse order, so we need to reverse the array so that events are processed in chronological order.

Co-authored-by: Andi <[email protected]>
  • Loading branch information
ashway83 and Supereg authored Sep 13, 2022
1 parent f8ff248 commit d256005
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/util/eventedhttp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,10 @@ export class HAPConnection extends EventEmitter {
private writeEventNotification(notification: EventNotification): void {
debugCon("[%s] Sending HAP event notifications %o", this.remoteAddress, notification.characteristics);

// Apple backend processes events in reverse order, so we need to reverse the array
// so that events are processed in chronological order.
notification.characteristics.reverse();

const dataBuffer = Buffer.from(JSON.stringify(notification), "utf8");
const header = Buffer.from(
"EVENT/1.0 200 OK\r\n" +
Expand Down

0 comments on commit d256005

Please sign in to comment.