From 32c6532a4f4f6107ad340abeab8c50c9a361e21a Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Sat, 20 Apr 2024 13:03:54 -0500 Subject: [PATCH] logging ?! --- index.js | 4 +++- static/index.html | 5 ++--- static/main.js | 16 +++++++++------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index effd228..0966ce7 100644 --- a/index.js +++ b/index.js @@ -42,6 +42,7 @@ app.use(pageUpdater.middleWare) var sockets = [] + wsServer = WebSocket.Server; let server = require('http').createServer() @@ -54,6 +55,7 @@ wsServer = new wsServer({ server.on('request', app) wsServer.on("connection", function connection(socket) { + console.log("BALLS") socket.on('message', function message(data) { data = JSON.parse(data) if (data.op == 3) { @@ -72,10 +74,10 @@ wsServer.on("connection", function connection(socket) { socket.send(`{ "op": 1 }`) sockets.push({ socket, lastPing: Date.now() }) - }) + process.on('uncaughtException', (err, origin) => { fs.writeSync( process.stderr.fd, diff --git a/static/index.html b/static/index.html index 623d306..f22950e 100644 --- a/static/index.html +++ b/static/index.html @@ -45,8 +45,8 @@ - +

Hi! I'm Violet, a 15 year old web and game developer. I make server-sided dynamic websites, with no Javascript required! I'm currently making games in the Godot Engine, and my dynamic sites in NodeJS.

@@ -58,7 +58,6 @@ {BRANCH_NAME} site FileShare
-
{CUSTOM_STATUS} diff --git a/static/main.js b/static/main.js index d39a9eb..e0a4bb8 100644 --- a/static/main.js +++ b/static/main.js @@ -58,14 +58,16 @@ window.onload = function () { } } -function socketeer() { - var lanyard = new WebSocket('wss://beta.violets-purgatory.dev') +var lastPong = Date.now() - lanyard.onerror = (error) => { +function socketeer() { + var sock = new WebSocket('wss://beta.violets-purgatory.dev') + + sock.onerror = (error) => { console.log(error) } - lanyard.onclose = () => { + sock.onclose = () => { console.log("Connection Closed. Attempting Reconnect in 30 seconds.") setTimeout(() => { socketeer() @@ -73,19 +75,19 @@ function socketeer() { } function ping(dur) { - lanyard.send(JSON.stringify({ + sock.send(JSON.stringify({ op: 3 })) setTimeout(() => { ping(dur) if (Date.now() - lastPong > 120000) { - lanyard.close() + sock.close() console.log("Max duration since last pong exceeded- Closing socket.") } }, dur); } - lanyard.addEventListener("message", async (res) => { + sock.addEventListener("message", async (res) => { var data = JSON.parse(res.data) if (data.op == 1) { console.log("Connected to Discord Websocket!")