logs and package updates and shit

This commit is contained in:
sky
2025-11-14 21:51:43 -05:00
parent 1f13ba2afb
commit 5045f30a4e
3 changed files with 624 additions and 724 deletions

View File

@ -1,5 +1,8 @@
import { appendFile } from 'fs/promises';
import WebSocket, { WebSocketServer } from "ws";
const wss = new WebSocketServer({ noServer: true });
let dataFile = "data/online.txt";
wss.on("connection", function connection(ws, req, res) {
ws.send(`online=${wss.clients.size}`);
@ -30,4 +33,7 @@ server.on("upgrade", (request, socket, head) => {
wss.handleUpgrade(request, socket, head, (socket) => {
wss.emit("connection", socket, request);
});
});
});
setInterval(async () => {
await appendFile(dataFile, String(wss.clients.size) + "\n")
}, 10000)