summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-12-31 12:00:00 +1100
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-12-31 12:00:00 +1100
commit0a09abbbfadbdd38781e633cf9858d8e7b795866 (patch)
tree9cf07974d4a5ab946e7d8c2fc6487e6e88d622bb /src
parentUpdate build workflow to use v3 checkout and setup-node (diff)
downloadserver-0a09abbbfadbdd38781e633cf9858d8e7b795866.tar.xz
Add WS_LOGEVENTS and WS_VERBOSE env vars
Diffstat (limited to 'src')
-rw-r--r--src/gateway/events/Connection.ts16
-rw-r--r--src/gateway/events/Message.ts2
2 files changed, 17 insertions, 1 deletions
diff --git a/src/gateway/events/Connection.ts b/src/gateway/events/Connection.ts

index ee75212f..d47ac314 100644 --- a/src/gateway/events/Connection.ts +++ b/src/gateway/events/Connection.ts
@@ -12,7 +12,7 @@ import { Config } from "@fosscord/util"; var erlpack: any; try { erlpack = require("@yukikaze-bot/erlpack"); -} catch (error) {} +} catch (error) { } // TODO: check rate limit // TODO: specify rate limit in config @@ -39,6 +39,20 @@ export async function Connection( // `[Gateway] New connection from ${socket.ipAddress}, total ${this.clients.size}`, // ); + if (process.env.WS_LOGEVENTS) + [ + "close", + "error", + "upgrade", + //"message", + "open", + "ping", + "pong", + "unexpected-response" + ].forEach((x) => { + socket.on(x, (y) => console.log(x, y)); + }); + const { searchParams } = new URL(`http://localhost${request.url}`); // @ts-ignore socket.encoding = searchParams.get("encoding") || "json"; diff --git a/src/gateway/events/Message.ts b/src/gateway/events/Message.ts
index a88495f6..57af0c69 100644 --- a/src/gateway/events/Message.ts +++ b/src/gateway/events/Message.ts
@@ -33,6 +33,8 @@ export async function Message(this: WebSocket, buffer: WS.Data) { } else return this.close(CLOSECODES.Decode_error); + if (process.env.WS_VERBOSE) console.log(`[Websocket] Incomming message: ${JSON.stringify(data)}`); + check.call(this, PayloadSchema, data); // @ts-ignore