/
AuthHello.ts
35 lines (30 loc) · 1.09 KB
/
AuthHello.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Platform, SendOption } from "@skeldjs/constant";
import { BaseRootPacket } from "@skeldjs/protocol";
import { HazelReader, HazelWriter, VersionInfo } from "@skeldjs/util";
export class AuthHelloPacket extends BaseRootPacket {
static messageTag = SendOption.Hello as const;
messageTag = SendOption.Hello as const;
constructor(
public readonly nonce: number,
public readonly clientVersion: VersionInfo,
public readonly platform: Platform,
public readonly authId: string
) {
super();
}
static Deserialize(reader: HazelReader) {
const nonce = reader.uint16(true);
reader.jump(1);
const clientVersion = reader.read(VersionInfo);
const platform = reader.uint8();
const authId = reader.string();
return new AuthHelloPacket(nonce, clientVersion, platform, authId);
}
Serialize(writer: HazelWriter) {
writer.uint16(this.nonce, true);
writer.uint8(0);
writer.write(this.clientVersion);
writer.uint8(this.platform);
writer.string(this.authId);
}
}