VOICE_STATE_UPDATE implementation, fix #210

This commit is contained in:
AlTech98
2021-09-02 19:33:04 +02:00
parent c410fbcc0d
commit 8ff56b1f9e
11 changed files with 142 additions and 24 deletions
+4 -2
View File
@@ -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);
}
+3
View File
@@ -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);
}
}