Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 68b3ed7

Browse files
committed
ping display
1 parent 9b2006d commit 68b3ed7

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

.gitpod.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This configuration file was automatically generated by Gitpod.
2+
# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
3+
# and commit this file to your remote git repository to share the goodness with others.
4+
5+
tasks:
6+
- init: npm install
7+
command: npm run start
8+
9+

index.html

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,38 @@
1212

1313
<script src="/socket.io/socket.io.js"></script>
1414

15+
<h1 id="status">Input-Server Loading</h1>
16+
1517
Select Instance:
1618
<select value="alpha" id="sel"></select>
1719

20+
<br />
21+
<span id="ping">Loading ping...</span>
22+
1823
<script>
19-
var socket = io();
24+
function msg(message){
25+
document.getElementById("status").innerText = message;
26+
}
27+
28+
const socket = io();
29+
socket.on("connected", () => msg("Socket connected. "));
2030

2131
socket.on("identify", () => {
32+
msg("Identifier request ok...");
2233
socket.emit("controller");
2334
socket.emit("instances");
35+
// Sync instances list
36+
setInterval(() => {
37+
socket.emit("instances");
38+
}, 10 * 1000);
39+
setInterval(() => {
40+
console.log("Sent ping command");
41+
socket.emit("loopback", Date.now());
42+
}, 3 * 1000);
43+
44+
socket.on("loopback", (start) => {
45+
document.getElementById("ping").innerText = "Ping: " + (Date.now() - start) + "ms";
46+
});
2447
});
2548

2649
socket.on("instanceList", (instances) => {

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ io.on('connection', (socket) => {
2323
socket.emit("identify",Date.now());
2424
socket.emit("hello","world",10);
2525

26+
socket.on("loopback", (c) => socket.emit("loopback",c));
2627

2728
socket.on("instances", () => {
2829
socket.emit("instanceList", instances);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)