🐛 fix hearbeat gateway
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user