mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
add support for new advert push codes when contacts are set to manual add
This commit is contained in:
parent
24d330b189
commit
2588af9a28
2 changed files with 23 additions and 2 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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, {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue