added websocket smol server
This commit is contained in:
1 parent
afa63acf85
commit
d59a7fc6b5
6 files changed
+250
-3
No files matched your search
@@ -0,0 +1,19 @@
|
||||
const uptime = document.querySelector('#time')
|
||||
const ws = new WebSocket('ws://172.16.17.21:8080');
|
||||
ws.onopen = () => {
|
||||
ws.send('Hello Server!');
|
||||
}
|
||||
|
||||
ws.onmessage = (e) => {
|
||||
console.log('Received:', e.data);
|
||||
var jsondata = JSON.parse(e.data);
|
||||
if (jsondata.uptime.hour === '0' && jsondata.uptime.minute === '0') {
|
||||
uptime.innerHTML = jsondata.uptime.second + "s "
|
||||
return
|
||||
}
|
||||
if (jsondata.uptime.hour === '0') {
|
||||
uptime.innerHTML = jsondata.uptime.minute + "m " + jsondata.uptime.second + "s "
|
||||
return
|
||||
}
|
||||
uptime.innerHTML = jsondata.uptime.hour + "h " + jsondata.uptime.minute + "m " + jsondata.uptime.second + "s "
|
||||
}
|
||||
Reference in new issue
Block a user