blob: 4a34477f930d72bf15a6e5b7949fe56a7911ac1c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import { instanceOf } from "lambert-server";
import { CLOSECODES } from "../util/Constants";
import WebSocket from "../util/WebSocket";
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;
}
}
|