mirror of
https://github.com/meshcore-dev/meshcore.js.git
synced 2026-04-20 22:13:49 +00:00
handle export contact response
This commit is contained in:
parent
12276302a7
commit
df3c032acd
2 changed files with 14 additions and 0 deletions
|
|
@ -15,6 +15,11 @@ class BufferReader {
|
|||
return data;
|
||||
}
|
||||
|
||||
readRemainingBytes() {
|
||||
const remainingBytesCount = this.buffer.length - this.pointer;
|
||||
return this.readBytes(remainingBytesCount);
|
||||
}
|
||||
|
||||
readString() {
|
||||
const remainingBytesCount = this.buffer.length - this.pointer;
|
||||
const remainingBytes = this.readBytes(remainingBytesCount);
|
||||
|
|
|
|||
|
|
@ -195,6 +195,8 @@ class Connection extends EventEmitter {
|
|||
this.onEndOfContactsResponse(bufferReader);
|
||||
} else if(responseCode === Constants.ResponseCodes.Sent){
|
||||
this.onSentResponse(bufferReader);
|
||||
} else if(responseCode === Constants.ResponseCodes.ExportContact){
|
||||
this.onExportContactResponse(bufferReader);
|
||||
} else if(responseCode === Constants.PushCodes.Advert){
|
||||
this.onAdvertPush(bufferReader);
|
||||
} else if(responseCode === Constants.PushCodes.PathUpdated){
|
||||
|
|
@ -281,6 +283,13 @@ class Connection extends EventEmitter {
|
|||
});
|
||||
}
|
||||
|
||||
onExportContactResponse(bufferReader) {
|
||||
const raw = bufferReader.readRemainingBytes();
|
||||
this.emit(Constants.ResponseCodes.ExportContact, {
|
||||
advertPacketBytes: raw,
|
||||
});
|
||||
}
|
||||
|
||||
onSelfInfoResponse(bufferReader) {
|
||||
this.emit(Constants.ResponseCodes.SelfInfo, {
|
||||
type: bufferReader.readByte(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue