-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
53 lines (41 loc) · 973 Bytes
/
test.js
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
// @flow
import { hexy } from 'hexy';
// prettier-ignore
let buff: Buffer = Buffer.from([
0xef,
0x07, 0x00, 0x47, 0x1b,
0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x47,
0x00, 0x00, 0x00, 0x1b
]);
console.log(hexy(buff, { width: 16, numbering: 'none', format: 'twos' }));
// ----- ----- ----- ----- -----
class BasePacket {
cmd: number;
}
class Packet extends BasePacket {
length: number;
constructor() {
super();
}
}
class LoginServerSeed extends Packet {
seed: number;
major: number;
minor: number;
revision: number;
patch: number;
constructor(buffer: Buffer) {
super();
this.cmd = 0xef;
this.length = 15;
this.seed = buffer.readUInt32BE(1);
this.major = buffer.readUInt32BE(5);
this.minor = buffer.readUInt32BE(9);
this.revision = buffer.readUInt32BE(13);
this.patch = buffer.readUInt32BE(17);
}
}
let ef: Packet = new LoginServerSeed(buff); // ?
console.table(ef);