mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
implement path updated push event
This commit is contained in:
parent
845f9d6d19
commit
5735dc8b66
2 changed files with 15 additions and 0 deletions
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue