diff --git a/src/gateway/listener/listener.ts b/src/gateway/listener/listener.ts
index 96eac986..90f7e4b1 100644
--- a/src/gateway/listener/listener.ts
+++ b/src/gateway/listener/listener.ts
@@ -17,25 +17,24 @@
*/
import {
+ Ban,
+ EVENTEnum,
+ EventOpts,
getPermission,
- Permissions,
- RabbitMQ,
listenEvent,
- EventOpts,
ListenEventOpts,
Member,
- EVENTEnum,
- Relationship,
Message,
NewUrlUserSignatureData,
- GuildMemberAddEvent,
- Ban,
+ Permissions,
+ RabbitMQ,
+ Recipient,
+ Relationship,
} from "@spacebar/util";
-import { OPCODES } from "../util/Constants";
+import { CLOSECODES, OPCODES } from "../util/Constants";
import { Send } from "../util/Send";
import { WebSocket } from "@spacebar/gateway";
import { Channel as AMQChannel } from "amqplib";
-import { Recipient } from "@spacebar/util";
import * as console from "node:console";
import { PublicMember, RelationshipType } from "@spacebar/schemas";
import { bgRedBright } from "picocolors";
@@ -208,6 +207,27 @@ async function consume(this: WebSocket, opts: EventOpts) {
opts.acknowledge?.();
// console.log("event", event);
+ // special codes
+ switch (event) {
+ case "SB_SESSION_CLOSE":
+ // TODO: what do we even send here?
+ await Send(this, {
+ op: OPCODES.Reconnect,
+ s: this.sequence++,
+ d: opts.reconnect_delay ?? opts.data ?? 1000,
+ });
+ this.close(1000); // not a discord close code, standard WS "Normal Closure"
+ return;
+ case "SB_SESSION_REMOVE":
+ // TODO: what do we even send here?
+ await Send(this, {
+ op: OPCODES.Invalid_Session,
+ s: this.sequence++,
+ });
+ this.close(CLOSECODES.Invalid_session); // TODO: this is deprecated?
+ return;
+ }
+
// subscription managment
switch (event) {
case "GUILD_MEMBER_REMOVE":
diff --git a/src/gateway/util/Constants.ts b/src/gateway/util/Constants.ts
index af5fa1a5..3e4599c6 100644
--- a/src/gateway/util/Constants.ts
+++ b/src/gateway/util/Constants.ts
@@ -42,7 +42,7 @@ export enum OPCODES {
Stream_Set_Paused = 22,
Request_Application_Commands = 24,
// We don't know the names for these:
- ThirtySix = 36, // this is just a guild id?
+ Request_Channel_Statuses = 36, // this is just a guild id?
Guild_Subscriptions_Bulk = 37, // Already implemented it seems?
SetQoS = 40,
ClientInitSession = 41,
diff --git a/src/util/interfaces/Event.ts b/src/util/interfaces/Event.ts
index 6971a61a..28ae0b54 100644
--- a/src/util/interfaces/Event.ts
+++ b/src/util/interfaces/Event.ts
@@ -60,6 +60,7 @@ export interface Event {
event: EVENT;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data?: any;
+ reconnect_delay?: number;
origin?: string;
}
@@ -848,4 +849,4 @@ export type EVENT =
| "THREAD_MEMBERS_UPDATE"
| CUSTOMEVENTS;
-export type CUSTOMEVENTS = "INVALIDATED" | "RATELIMIT";
+export type CUSTOMEVENTS = "INVALIDATED" | "RATELIMIT" | "SB_SESSION_REMOVE" | "SB_SESSION_CLOSE";
|