From 6e13d33b2dc34c8633b627e2d5f0bbabce23ea50 Mon Sep 17 00:00:00 2001 From: xangelo Date: Wed, 25 May 2022 16:14:22 -0400 Subject: [PATCH] add online user count + servertime --- public/game.html | 4 ++++ public/scifi.css | 4 ++++ src/api.ts | 11 +++++++++++ 3 files changed, 19 insertions(+) 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); -- 2.25.1