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),