summary refs log tree commit diff
path: root/src/webrtc/events/Close.ts
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-25 18:24:21 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-25 23:35:18 +1000
commitf44f5d7ac2d24ff836c2e1d4b2fa58da04b13052 (patch)
treea6655c41bb3db79c30fd876b06ee60fe9cf70c9b /src/webrtc/events/Close.ts
parentAllow edited_timestamp to passthrough in handleMessage (diff)
downloadserver-f44f5d7ac2d24ff836c2e1d4b2fa58da04b13052.tar.xz
Refactor to mono-repo + upgrade packages
Diffstat (limited to 'src/webrtc/events/Close.ts')
-rw-r--r--src/webrtc/events/Close.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/webrtc/events/Close.ts b/src/webrtc/events/Close.ts
new file mode 100644
index 00000000..1c203653
--- /dev/null
+++ b/src/webrtc/events/Close.ts
@@ -0,0 +1,9 @@
+import { WebSocket } from "@fosscord/gateway";
+import { Session } from "@fosscord/util";
+
+export async function onClose(this: WebSocket, code: number, reason: string) {
+	console.log("[WebRTC] closed", code, reason.toString());
+
+	if (this.session_id) await Session.delete({ session_id: this.session_id });
+	this.removeAllListeners();
+}
\ No newline at end of file