-
Notifications
You must be signed in to change notification settings - Fork 4
/
reconnect-packet.ts
70 lines (65 loc) · 1.59 KB
/
reconnect-packet.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { Writer } from '../../writer';
import { Reader } from '../../reader';
import { PacketType } from '../../packet-type';
import { Packet } from '../../packet';
/**
* Received to instruct the client to connect to a new host.
*/
export class ReconnectPacket implements Packet {
type = PacketType.RECONNECT;
propagate = true;
//#region packet-specific members
/**
* The name of the new host.
*/
name: string;
/**
* The address of the new host.
*/
host: string;
/**
* > Unknown.
*/
stats: string;
/**
* The port of the new host.
*/
port: number;
/**
* The `gameId` to send in the next `HelloPacket`.
*/
gameId: number;
/**
* The `keyTime` to send in the next `HelloPacket`.
*/
keyTime: number;
/**
* The `key` to send in the next `HelloPacket`.
*/
key: number[];
/**
* Whether or not the new host is from the arena.
*/
isFromArena: boolean;
//#endregion
read(reader: Reader): void {
this.name = reader.readString();
this.host = reader.readString();
this.stats = reader.readString();
this.port = reader.readInt32();
this.gameId = reader.readInt32();
this.keyTime = reader.readInt32();
this.isFromArena = reader.readBoolean();
this.key = reader.readByteArray();
}
write(writer: Writer): void {
writer.writeString(this.name);
writer.writeString(this.host);
writer.writeString(this.stats);
writer.writeInt32(this.port);
writer.writeInt32(this.gameId);
writer.writeInt32(this.keyTime);
writer.writeBoolean(this.isFromArena);
writer.writeByteArray(this.key);
}
}