From: xangelo Date: Wed, 25 May 2022 20:14:22 +0000 (-0400) Subject: add online user count + servertime X-Git-Url: https://git.xangelo.ca/?a=commitdiff_plain;h=6e13d33b2dc34c8633b627e2d5f0bbabce23ea50;p=browser-rts.git add online user count + servertime --- diff --git a/public/game.html b/public/game.html index 39295a1..2ac4998 100644 --- a/public/game.html +++ b/public/game.html @@ -69,6 +69,10 @@ +
+
+
+
diff --git a/public/scifi.css b/public/scifi.css index 4dc0085..7fc5c33 100644 --- a/public/scifi.css +++ b/public/scifi.css @@ -373,3 +373,7 @@ form > div { #chat-form button { max-width: 150px; } + +#stats { + margin-top: 1rem; +} diff --git a/src/api.ts b/src/api.ts index b086ff3..0c37379 100644 --- a/src/api.ts +++ b/src/api.ts @@ -373,6 +373,17 @@ server.post<{body: {message: string}}, void>('/chat', async req => { return; }); +server.get('/server-stats', async req => { + const date = new Date(); + return ` +
+ ${(await server.ws.allSockets()).size} Online
+ + Server Time: ${date.getHours()}:${date.getMinutes()} + +
`; +}); + server.ws.on('connection', async socket => { const auth = server.authFromUrl(socket.request.headers['referer']); const acct = await accountRepo.validate(auth.authInfo.accountId, auth.authInfo.token);