Commit 70e80afd authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement localMessage.

parent 63e1a6f4
...@@ -1738,6 +1738,13 @@ function addToChatbox(peerId, dest, nick, time, privileged, kind, message) { ...@@ -1738,6 +1738,13 @@ function addToChatbox(peerId, dest, nick, time, privileged, kind, message) {
return message; return message;
} }
/**
* @param {string} message
*/
function localMessage(message) {
return addToChatbox(null, null, null, Date.now(), false, null, message);
}
function clearChat() { function clearChat() {
lastMessage = {}; lastMessage = {};
document.getElementById('box').textContent = ''; document.getElementById('box').textContent = '';
...@@ -1794,7 +1801,7 @@ commands.help = { ...@@ -1794,7 +1801,7 @@ commands.help = {
let s = ''; let s = '';
for(let i = 0; i < cs.length; i++) for(let i = 0; i < cs.length; i++)
s = s + cs[i] + '\n'; s = s + cs[i] + '\n';
addToChatbox(null, null, null, Date.now(), false, null, s); localMessage(s);
} }
}; };
...@@ -1812,7 +1819,7 @@ commands.set = { ...@@ -1812,7 +1819,7 @@ commands.set = {
let s = ""; let s = "";
for(let key in settings) for(let key in settings)
s = s + `${key}: ${JSON.stringify(settings[key])}\n`; s = s + `${key}: ${JSON.stringify(settings[key])}\n`;
addToChatbox(null, null, null, Date.now(), false, null, s); localMessage(s);
return; return;
} }
let p = parseCommand(r); let p = parseCommand(r);
...@@ -2109,17 +2116,14 @@ async function relayTest() { ...@@ -2109,17 +2116,14 @@ async function relayTest() {
commands['relay-test'] = { commands['relay-test'] = {
f: async (c, r) => { f: async (c, r) => {
addToChatbox(null, null, null, Date.now(), false, null, localMessage('Relay test in progress...');
`Relay test in progress...`);
try { try {
let s = Date.now(); let s = Date.now();
let rtt = await relayTest(); let rtt = await relayTest();
let e = Date.now(); let e = Date.now();
addToChatbox(null, null, null, Date.now(), false, null, localMessage(`Relay test successful in ${e-s}ms, RTT ${rtt}ms`);
`Relay test successful in ${e-s}ms, RTT ${rtt}ms`);
} catch(e) { } catch(e) {
addToChatbox(null, null, null, Date.now(), false, null, localMessage(`Relay test failed: ${e}`);
`Relay test failed: ${e}`);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment