diff --git a/index.html b/index.html index fb178ef..e57bf2c 100644 --- a/index.html +++ b/index.html @@ -249,11 +249,15 @@ await this.loadContacts(); - this.connection.on(Constants.PushCodes.Advert, async () => { - console.log("on advert"); + this.connection.on(Constants.PushCodes.Advert, async (data) => { + console.log("Advert", data); await this.loadContacts(); }); + this.connection.on(Constants.PushCodes.NewAdvert, async (data) => { + console.log("NewAdvert", data); + }); + this.connection.on(Constants.PushCodes.PathUpdated, async (event) => { console.log("PathUpdated", event); await this.loadContacts(); diff --git a/src/connection/connection.js b/src/connection/connection.js index 30937f3..c492670 100644 --- a/src/connection/connection.js +++ b/src/connection/connection.js @@ -335,6 +335,8 @@ class Connection extends EventEmitter { this.onLogRxDataPush(bufferReader); } else if(responseCode === Constants.PushCodes.TraceData){ this.onTraceDataPush(bufferReader); + } else if(responseCode === Constants.PushCodes.NewAdvert){ + this.onNewAdvertPush(bufferReader); } else { console.log(`unhandled frame: code=${responseCode}`, frame); } @@ -413,6 +415,21 @@ class Connection extends EventEmitter { }); } + onNewAdvertPush(bufferReader) { + this.emit(Constants.PushCodes.NewAdvert, { + publicKey: bufferReader.readBytes(32), + type: bufferReader.readByte(), + flags: bufferReader.readByte(), + outPathLen: bufferReader.readInt8(), + outPath: bufferReader.readBytes(64), + advName: bufferReader.readCString(32), + lastAdvert: bufferReader.readUInt32LE(), + advLat: bufferReader.readUInt32LE(), + advLon: bufferReader.readUInt32LE(), + lastMod: bufferReader.readUInt32LE(), + }); + } + onOkResponse(bufferReader) { this.emit(Constants.ResponseCodes.Ok, {