handle export contact response

This commit is contained in:
liamcottle 2025-02-15 21:38:24 +13:00
parent 12276302a7
commit df3c032acd
2 changed files with 14 additions and 0 deletions

View file

@ -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);

View file

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