-
Notifications
You must be signed in to change notification settings - Fork 4
/
packet.ts
35 lines (33 loc) · 1.01 KB
/
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
import { PacketType } from './packet-type';
import { Reader } from './reader';
import { Writer } from './writer';
/**
* A packet which can be both received from the server and sent to the server.
*/
export interface DataPacket {
/**
* Writes the packet to the `writer` according to the packet's structure.
* @param writer The writer to write to.
*/
write(writer: Writer): void;
/**
* Reads data from the `reader` according to the structure of the packet.
* @param reader The reader to read from.
*/
read(reader: Reader): void;
}
export interface Packet extends DataPacket {
/**
* The type of packet.
*/
type: PacketType;
/**
* Whether or not the packet should keep invoking packet hooks.
*
* If this is set to `false` by a packet hook, then that packet hook will
* be the last one which receives the packet. The client's packet hooks are
* always the last ones to be called, so if this is set to `false` the packet
* will not reach the client.
*/
propagate: boolean;
}