mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-22 10:42:34 +00:00
⚡ zlib compression
This commit is contained in:
1 parent
ccfa61ca63
commit
e4115d13ef
3 files changed
+18
-2
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import erlpack from "erlpack";
|
||||
import { promisify } from "util";
|
||||
import { Payload } from "../util/Constants";
|
||||
import { deflateSync } from "zlib";
|
||||
|
||||
import WebSocket from "./WebSocket";
|
||||
|
||||
@@ -11,6 +12,11 @@ export async function Send(socket: WebSocket, data: Payload) {
|
||||
else if (socket.encoding === "json") buffer = JSON.stringify(data);
|
||||
|
||||
// TODO: compression
|
||||
if (socket.deflate) {
|
||||
socket.deflate.write(buffer);
|
||||
socket.deflate.flush();
|
||||
return;
|
||||
}
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
socket.send(buffer, (err) => {
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import { Intents } from "fosscord-server-util";
|
||||
import WS, { Server, Data } from "ws";
|
||||
import { Deflate } from "zlib";
|
||||
|
||||
interface WebSocket extends WS {
|
||||
version: number;
|
||||
user_id: bigint;
|
||||
encoding: "etf" | "json";
|
||||
compress?: "zlib-stream";
|
||||
deflate?: Deflate;
|
||||
heartbeatTimeout: NodeJS.Timeout;
|
||||
readyTimeout: NodeJS.Timeout;
|
||||
intents: Intents;
|
||||
sequence: number;
|
||||
}
|
||||
|
||||
export default WebSocket;
|
||||
|
||||
Reference in new issue
Block a user