Skip to content

Commit b5682bf

Browse files
committed
More diagnostics
1 parent d95f4ee commit b5682bf

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
</div>
2626
<div class="container">
2727
<div id="demo">This is a demo only! Download and serve the repo locally to test the gamepad</div>
28+
<div id="stats">
29+
lat:
30+
</div>
2831
<p>Socket Joy Alpha</p>
2932
<div class="bumpers">
3033
<div id="left-bumper">L</div>

socketjoy.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,16 @@ var isLocal = isLocalNetwork();
1414
// var isLocal = false;
1515

1616
var sock;
17-
17+
var lat;
1818
if (isLocal) {
1919
sock = io(SERVER_IP);
20+
21+
// Start measuring connection latency
22+
lat = 0;
23+
sock.on('pong', function(ms) {
24+
lat = ms;
25+
document.getElementById("stats").innerHTML = "lat: " + ms + "ms";
26+
});
2027
} else {
2128
// Notify user that this is a demo only
2229
var demo = document.getElementById('demo');
@@ -26,6 +33,7 @@ if (isLocal) {
2633

2734
var conf = document.getElementsByClassName('configure')
2835

36+
// Rewrite this method to a propper modal-based config menu
2937
function updateIP() {
3038
var ip = prompt('Please enter the j2dx server IP')
3139
console.log(ip)

style.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ body {
2828
height: 100%;
2929
touch-action: none; /* Disable panning and zooming */
3030
}
31+
/* stats */
32+
#stats{
33+
display: none;
34+
position: absolute;
35+
top: 0;
36+
left: 0;
37+
}
38+
3139
/* Cog button */
3240
.configure{
3341
font-size: 30px;

0 commit comments

Comments
 (0)