From 5735dc8b66eaa4ebb7f0e81359fe2b6b2ad7918f Mon Sep 17 00:00:00 2001 From: liamcottle Date: Wed, 12 Feb 2025 00:48:02 +1300 Subject: [PATCH] implement path updated push event --- index.html | 7 +++++++ src/connection/connection.js | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/index.html b/index.html index 2a6b407..88bd244 100644 --- a/index.html +++ b/index.html @@ -165,13 +165,20 @@ } }, async onConnected() { + console.log("connected"); await this.loadSelfInfo(); await this.loadContacts(); + this.connection.on(Constants.PushCodes.Advert, async () => { console.log("on advert"); await this.loadContacts(); }); + + this.connection.on(Constants.PushCodes.PathUpdated, async (event) => { + console.log("PathUpdated", event); + }); + }, onDisconnected() { console.log("disconnected"); diff --git a/src/connection/connection.js b/src/connection/connection.js index d023849..344864c 100644 --- a/src/connection/connection.js +++ b/src/connection/connection.js @@ -163,6 +163,8 @@ class Connection extends EventEmitter { this.onSentResponse(bufferReader); } else if(responseCode === Constants.PushCodes.Advert){ this.onAdvertPush(bufferReader); + } else if(responseCode === Constants.PushCodes.PathUpdated){ + this.onPathUpdatedPush(bufferReader); } else if(responseCode === Constants.PushCodes.SendConfirmed){ this.onSendConfirmedPush(bufferReader); } else if(responseCode === Constants.PushCodes.MsgWaiting){ @@ -179,6 +181,12 @@ class Connection extends EventEmitter { }); } + onPathUpdatedPush(bufferReader) { + this.emit(Constants.PushCodes.PathUpdated, { + publicKey: bufferReader.readBytes(32), + }); + } + onSendConfirmedPush(bufferReader) { this.emit(Constants.PushCodes.SendConfirmed, { ackCode: bufferReader.readBytes(4),