mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-22 02:12:40 +01:00
Add WS_LOGEVENTS and WS_VERBOSE env vars
This commit is contained in:
parent
28a309bcdc
commit
6ca65a19f2
@ -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";
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user