From e3d1dc1eed5eac225c4a0c6ab65728d5e440088b Mon Sep 17 00:00:00 2001 From: Daryl Ronningen Date: Fri, 16 Jul 2021 20:23:15 -0700 Subject: [PATCH] fix(gateway): fix identify not sending (try 3) --- src/gateway/gatewayClient.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/gateway/gatewayClient.ts b/src/gateway/gatewayClient.ts index 2fb1b33..70d1f03 100644 --- a/src/gateway/gatewayClient.ts +++ b/src/gateway/gatewayClient.ts @@ -8,7 +8,6 @@ import type { GatewayReceiveMessage, GatewaySendMessage } from '../utils/types'; export class GatewayClient { public client: Client; public connection: WebSocket | null; - public deflate: zlib.Deflate; public inflate: zlib.Inflate; private _heartbeatInterval: number; @@ -20,7 +19,6 @@ export class GatewayClient { this.client = client; this.connection = null; - this.deflate = new zlib.Deflate(); this.inflate = new zlib.Inflate(); this._heartbeatInterval = 0; @@ -73,7 +71,7 @@ export class GatewayClient { }, }); - this._sendHeartbeat(); + this._heartbeatIntervalTimer = setInterval(() => this._sendHeartbeat(), this._heartbeatInterval * 1000); break; default: break; @@ -84,15 +82,10 @@ export class GatewayClient { public send(data: GatewaySendMessage): void { if (!this.connection) throw new Error('You are not connected to the Discord WebSocket Gateway!'); - let parsedMessage: Buffer | string; - - if (this.client.options.ws.compression) parsedMessage = this.deflate.process(JSON.stringify(data)); - else parsedMessage = JSON.stringify(data); - - this.connection.send(parsedMessage); + this.connection.send(JSON.stringify(data)); } private _sendHeartbeat(): void { - this._heartbeatIntervalTimer = setInterval(() => this.send({ op: 1, d: this._sequence }), this._heartbeatInterval * 1000); + this.send({ op: 1, d: this._sequence }); } }