ping command for two-way-delay
This commit is contained in:
parent
26bd3ddb6f
commit
6f1ce9fcad
|
@ -67,7 +67,8 @@ function cmd_help() {
|
||||||
" -exec Execute arbitrary math and logic equations<br>" +
|
" -exec Execute arbitrary math and logic equations<br>" +
|
||||||
" -nick Choose your username. Do not use spaces in it<br>" +
|
" -nick Choose your username. Do not use spaces in it<br>" +
|
||||||
" -msg Open a direct chat to the provided user by name<br>" +
|
" -msg Open a direct chat to the provided user by name<br>" +
|
||||||
" -ls List all connected users by name and id";
|
" -ls List all connected users by name and id<br>" +
|
||||||
|
" -ping Ping the host to request two-way-delay";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display 'about' message
|
// Display 'about' message
|
||||||
|
@ -206,3 +207,9 @@ function cmd_ls() {
|
||||||
requestUsernames();
|
requestUsernames();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ping host for two-way-delay
|
||||||
|
function cmd_ping() {
|
||||||
|
requestPing();
|
||||||
|
return null;
|
||||||
|
}
|
|
@ -150,3 +150,15 @@ function requestUsernames() {
|
||||||
outputText({ output });
|
outputText({ output });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ping host for two-way-delay
|
||||||
|
function requestPing() {
|
||||||
|
const startTime = new Date();
|
||||||
|
fetch('/ping').then(res => {
|
||||||
|
if (res.status !== 200)
|
||||||
|
return;
|
||||||
|
const diff = new Date() - startTime;
|
||||||
|
const output = `Host responded after ${diff}ms.`;
|
||||||
|
outputText({output})
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user