🐛 fix hearbeat gateway

This commit is contained in:
Flam3rboy
2021-04-06 14:15:13 +02:00
parent 509394b592
commit 7279df5efb
6 changed files with 21 additions and 21 deletions
+2 -2
View File
@@ -3,10 +3,10 @@ import { Send } from "../util/Send";
import { setHeartbeat } from "../util/setHeartbeat";
import WebSocket from "../util/WebSocket";
export function onHeartbeat(this: WebSocket, data: Payload) {
export async function onHeartbeat(this: WebSocket, data: Payload) {
// TODO: validate payload
setHeartbeat(this);
Send(this, { op: 11 });
await Send(this, { op: 11 });
}
+1 -1
View File
@@ -3,5 +3,5 @@ import { CLOSECODES, Payload } from "../util/Constants";
import WebSocket from "../util/WebSocket";
export function onResume(this: WebSocket, data: Payload) {
return this.close(CLOSECODES.Session_timed_out);
return this.close(CLOSECODES.Invalid_session);
}
+1
View File
@@ -6,6 +6,7 @@ export function check(this: WebSocket, schema: any, data: any) {
try {
if (instanceOf(schema, data) !== true) throw "invalid";
} catch (error) {
console.error(error);
// invalid payload
this.close(CLOSECODES.Decode_error);
return false;