summary refs log tree commit diff
path: root/gateway/src/events
diff options
context:
space:
mode:
authorAlTech98 <altech123159@gmail.com>2021-09-02 19:33:04 +0200
committerAlTech98 <altech123159@gmail.com>2021-09-02 19:33:04 +0200
commit9dac7ddf9eb43c4fac263d00b0208e6d337506fd (patch)
treefe50372026cc776e30ae36ed349553c2d3179ad4 /gateway/src/events
parent:art: update openapi title (diff)
downloadserver-9dac7ddf9eb43c4fac263d00b0208e6d337506fd.tar.xz
VOICE_STATE_UPDATE implementation, fix #210
Diffstat (limited to 'gateway/src/events')
-rw-r--r--gateway/src/events/Close.ts6
-rw-r--r--gateway/src/events/Connection.ts3
2 files changed, 7 insertions, 2 deletions
diff --git a/gateway/src/events/Close.ts b/gateway/src/events/Close.ts
index f1a8fa9b..26f4e7df 100644
--- a/gateway/src/events/Close.ts
+++ b/gateway/src/events/Close.ts
@@ -1,7 +1,9 @@
-import WebSocket from "ws";
+import WebSocket from "../util/WebSocket";
 import { Message } from "./Message";
+import {Session} from "@fosscord/util";
 
-export function Close(this: WebSocket, code: number, reason: string) {
+export async function Close(this: WebSocket, code: number, reason: string) {
+	await Session.delete({session_id: this.session_id})
 	// @ts-ignore
 	this.off("message", Message);
 }
diff --git a/gateway/src/events/Connection.ts b/gateway/src/events/Connection.ts
index fed3c611..1af484eb 100644
--- a/gateway/src/events/Connection.ts
+++ b/gateway/src/events/Connection.ts
@@ -7,6 +7,7 @@ import { Send } from "../util/Send";
 import { CLOSECODES, OPCODES } from "../util/Constants";
 import { createDeflate } from "zlib";
 import { URL } from "url";
+import {Session} from "@fosscord/util";
 var erlpack: any;
 try {
 	erlpack = require("erlpack");
@@ -56,10 +57,12 @@ export async function Connection(this: Server, socket: WebSocket, request: Incom
 		});
 
 		socket.readyTimeout = setTimeout(() => {
+			Session.delete({session_id: socket.session_id}) //should we await?
 			return socket.close(CLOSECODES.Session_timed_out);
 		}, 1000 * 30);
 	} catch (error) {
 		console.error(error);
+		Session.delete({session_id: socket.session_id}) //should we await?
 		return socket.close(CLOSECODES.Unknown_error);
 	}
 }