Skip to content
Snippets Groups Projects
Commit 57e02c60 authored by echicken's avatar echicken :chicken:
Browse files

Send text in chunks if necessary

parent dd0daba6
No related branches found
No related tags found
No related merge requests found
......@@ -396,12 +396,16 @@ export default abstract class Device extends js.global.EventEmitter {
ackHandler,
replyId,
hopLimit,
}: ITextMessageParams): boolean {
}: ITextMessageParams): void {
const msgs = chunkText(text);
for (const msg of msgs) {
// @ts-expect-error It's fucken ambient okay?
const enc = new TextEncoder();
const payload = enc.encode(text);
const payload = enc.encode(msg);
if (payload.length > MAX_PAYLOAD) this.error(`sendText: payload length ${payload.length} exceeds maximum (${MAX_PAYLOAD})`);
return this.sendPacket({ payload, portNum: protobuf.Portnums.PortNum.TEXT_MESSAGE_APP, to, channel, wantAck, ackHandler, replyId, hopLimit });
const res = this.sendPacket({ payload, portNum: protobuf.Portnums.PortNum.TEXT_MESSAGE_APP, to, channel, wantAck, ackHandler, replyId, hopLimit });
if (!res) this.error(`failed to send text message`);
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment