blob: f0546a419a2ec55d2cef64c757a0d54a783bc31e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import { CLOSECODES, Payload } from "../util/Constants";
import WebSocket from "../util/WebSocket";
import { checkToken, IdentifySchema } from "fosscord-server-util";
import { setupListener } from "../listener/listener";
import { instanceOf } from "lambert-server";
export async function onIdentify(this: WebSocket, data: Payload) {
try {
clearTimeout(this.readyTimeout);
instanceOf(IdentifySchema, data.d);
const identify: IdentifySchema = data.d;
var decoded = await checkToken(identify.token);
this.userid = decoded.id;
await setupListener.call(this);
} catch (error) {
return this.close(CLOSECODES.Authentication_failed);
}
}
|