fix(gateway): fix identify not sending (try 3)
This commit is contained in:
parent
3788d1ef08
commit
e3d1dc1eed
1 changed files with 3 additions and 10 deletions
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue