Dev/post refactor fixes (#927)
* Re-introduce outgoing message logging Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Websocket dumping * Sentry user count on API * Generate session ID upon opening websocket, fix gateway dumps * Async file io in src/gateway/events/Message.ts Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Async file io in src/util/util/Config.ts Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Make pre-commit hook executable Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Fixed sync file io in src/util/util/Config.ts Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Fixed missing await call in src/util/util/AutoUpdate.ts Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Add comment to src/gateway/events/Connection.ts Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> * Clean up gateway dumping code Signed-off-by: TheArcaneBrony <myrainbowdash949@gmail.com> Co-authored-by: Madeline <46743919+MaddyUnderStars@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
Madeline
parent
da9ce34933
commit
6122374e4d
@@ -7,8 +7,27 @@ try {
|
||||
);
|
||||
}
|
||||
import { Payload, WebSocket } from "@fosscord/gateway";
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
|
||||
export function Send(socket: WebSocket, data: Payload) {
|
||||
if (process.env.WS_VERBOSE)
|
||||
console.log(`[Websocket] Outgoing message: ${JSON.stringify(data)}`);
|
||||
|
||||
if (process.env.WS_DUMP) {
|
||||
const id = socket.session_id || "unknown";
|
||||
|
||||
(async () => {
|
||||
await fs.mkdir(path.join("dump", id), {
|
||||
recursive: true,
|
||||
});
|
||||
await fs.writeFile(
|
||||
path.join("dump", id, `${Date.now()}.out.json`),
|
||||
JSON.stringify(data, null, 2),
|
||||
);
|
||||
})();
|
||||
}
|
||||
|
||||
let buffer: Buffer | string;
|
||||
if (socket.encoding === "etf") buffer = erlpack.pack(data);
|
||||
// TODO: encode circular object
|
||||
|
||||
Reference in New Issue
Block a user