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

'Fix' for string split w/regex, debug log, temporary crappy delay.

parent 57e02c60
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ export function getRandomId(): number {
}
function chunkText(str: string): string[] {
const arr = str.trim().split(/(\s+)/);
const arr = str.trim().split(/(\s+)/.source); // .source as hack to work around some polyfill shenanigans w/RegExp & String.split
const ret: string[] = [];
let s: string = '';
// @ts-expect-error shut up
......@@ -399,12 +399,14 @@ export default abstract class Device extends js.global.EventEmitter {
}: ITextMessageParams): void {
const msgs = chunkText(text);
for (const msg of msgs) {
if (this.debug) this.log(sbbsdefs.LOG_DEBUG, `Sending text: ${msg}`);
// @ts-expect-error It's fucken ambient okay?
const enc = new TextEncoder();
const payload = enc.encode(msg);
if (payload.length > MAX_PAYLOAD) this.error(`sendText: payload length ${payload.length} exceeds maximum (${MAX_PAYLOAD})`);
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`);
js.global.mswait(100);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment