zebra-report: echo sent message instantly (don't wait for slow transmit)
This commit is contained in:
parent
4eb0aab206
commit
db382f6d44
1 changed files with 9 additions and 7 deletions
|
|
@ -1680,27 +1680,29 @@ async function sendCurrentMsg() {
|
|||
if (!msg) return;
|
||||
if (!carrierOn) { logLine('err', 'start carrier first'); return; }
|
||||
const mode = currentMode();
|
||||
if (mode === 'passphrase' && !groupKey) { logLine('err', 'no room key'); return; }
|
||||
if (mode === 'pubkey' && !Array.from(peers.values()).some(p => p.sharedKey)) {
|
||||
logLine('err', 'no pubkey peers ready'); return;
|
||||
}
|
||||
/* must match the inbound decoder, which stays at ZEBRA_BAUD_HANDSHAKE for the
|
||||
* life of the link — data sent at any other baud won't decode on the far side. */
|
||||
const baud = ZEBRA_BAUD_HANDSHAKE;
|
||||
const handle = handleIn.value.trim() || 'me';
|
||||
/* echo immediately so the sender sees the message without waiting for the
|
||||
* (slow, multi-second at low baud) transmit to finish */
|
||||
logLine('me', `<span class="from">${escapeHtml(handle)}:</span> ${escapeHtml(msg)}`);
|
||||
$('msg-in').value = '';
|
||||
try {
|
||||
if (mode === 'passphrase') {
|
||||
if (!groupKey) { logLine('err', 'no room key'); return; }
|
||||
const ct = await aesEncrypt(groupKey, msg);
|
||||
await txFrame(await buildDataFrame(ct), baud);
|
||||
} else {
|
||||
let sent = 0;
|
||||
for (const p of peers.values()) {
|
||||
if (!p.sharedKey) continue;
|
||||
const ct = await aesEncrypt(p.sharedKey, msg);
|
||||
await txFrame(await buildDataFrame(ct), baud);
|
||||
sent++;
|
||||
}
|
||||
if (sent === 0) { logLine('err', 'no pubkey peers ready'); return; }
|
||||
}
|
||||
const handle = handleIn.value.trim() || 'me';
|
||||
logLine('me', `<span class="from">${escapeHtml(handle)}:</span> ${escapeHtml(msg)}`);
|
||||
$('msg-in').value = '';
|
||||
} catch (e) {
|
||||
logLine('err', 'send failed: ' + e.message);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue