@sanctumterra/raknet 1.1.8 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/client-events.d.ts +3 -3
- package/dist/client/client.js +3 -3
- package/dist/client/options.js +2 -2
- package/dist/client/receiver.d.ts +13 -19
- package/dist/client/receiver.js +198 -170
- package/dist/client/sender.d.ts +3 -3
- package/dist/client/sender.js +103 -41
- package/dist/packets/OpenConnectionReplyOne.d.ts +9 -0
- package/dist/packets/{open-connection-first-reply.js → OpenConnectionReplyOne.js} +12 -12
- package/dist/packets/{open-connection-second-reply.d.ts → OpenConnectionReplyTwo.d.ts} +2 -2
- package/dist/packets/{open-connection-second-reply.js → OpenConnectionReplyTwo.js} +10 -10
- package/dist/packets/OpenConnectionRequestOne.d.ts +8 -0
- package/dist/packets/{open-connection-first-request.js → OpenConnectionRequestOne.js} +9 -9
- package/dist/packets/{open-connection-second-request.d.ts → OpenConnectionRequestTwo.d.ts} +2 -2
- package/dist/packets/{open-connection-second-request.js → OpenConnectionRequestTwo.js} +11 -11
- package/dist/packets/index.d.ts +4 -4
- package/dist/packets/index.js +4 -4
- package/dist/tools/test.js +1 -1
- package/package.json +1 -1
- package/dist/packets/open-connection-first-reply.d.ts +0 -8
- package/dist/packets/open-connection-first-request.d.ts +0 -7
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Ack, Frame, FrameSet } from "@serenityjs/raknet";
|
|
2
|
-
import type {
|
|
2
|
+
import type { OpenConnectionReplyOne, OpenConnectionReplyTwo, UnconnectedPong } from "../packets";
|
|
3
3
|
interface ClientEvents {
|
|
4
4
|
tick: [];
|
|
5
5
|
close: [];
|
|
6
6
|
error: [error: Error];
|
|
7
7
|
"unconnected-pong": [UnconnectedPong];
|
|
8
|
-
"open-connection-
|
|
9
|
-
"open-connection-
|
|
8
|
+
"open-connection-reply-one": [OpenConnectionReplyOne];
|
|
9
|
+
"open-connection-reply-two": [OpenConnectionReplyTwo];
|
|
10
10
|
frameset: [FrameSet];
|
|
11
11
|
encapsulated: [Frame];
|
|
12
12
|
connect: [];
|
package/dist/client/client.js
CHANGED
|
@@ -18,19 +18,18 @@ class Client extends emitter_1.default {
|
|
|
18
18
|
this.status = raknet_1.Status.Disconnected;
|
|
19
19
|
this.options = { ...options_1.defaultOptions, ...options };
|
|
20
20
|
this.socket = options.socket ?? (0, node_dgram_1.createSocket)("udp4");
|
|
21
|
-
this.receiver = new receiver_1.Receiver(this
|
|
21
|
+
this.receiver = new receiver_1.Receiver(this);
|
|
22
22
|
this.sender = new sender_1.Sender(this);
|
|
23
23
|
}
|
|
24
24
|
async connect() {
|
|
25
25
|
this.ticker = setInterval(() => {
|
|
26
26
|
this.tick++;
|
|
27
27
|
this.emit("tick");
|
|
28
|
-
}, 50);
|
|
28
|
+
}, 50).unref();
|
|
29
29
|
this.tick++;
|
|
30
30
|
this.status = raknet_1.Status.Connecting;
|
|
31
31
|
const advertisement = await this.ping();
|
|
32
32
|
await sender_1.Sender.connect(this);
|
|
33
|
-
this.emit("connect");
|
|
34
33
|
return advertisement;
|
|
35
34
|
}
|
|
36
35
|
ping() {
|
|
@@ -42,6 +41,7 @@ class Client extends emitter_1.default {
|
|
|
42
41
|
close() {
|
|
43
42
|
this.emit("close");
|
|
44
43
|
this.socket.close();
|
|
44
|
+
// @ts-ignore
|
|
45
45
|
clearInterval(this.ticker);
|
|
46
46
|
}
|
|
47
47
|
disconnect() {
|
package/dist/client/options.js
CHANGED
|
@@ -6,9 +6,9 @@ const defaultOptions = {
|
|
|
6
6
|
host: "0.0.0.0",
|
|
7
7
|
port: 19132,
|
|
8
8
|
guid: BigInt(Math.floor(Math.random() * 9007199254740991)),
|
|
9
|
-
mtu:
|
|
9
|
+
mtu: 1492,
|
|
10
10
|
debug: false,
|
|
11
|
-
timeout:
|
|
11
|
+
timeout: 10000,
|
|
12
12
|
socket: undefined,
|
|
13
13
|
};
|
|
14
14
|
exports.defaultOptions = defaultOptions;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
2
|
import { Frame } from "@serenityjs/raknet";
|
|
4
|
-
import type { Socket } from "node:dgram";
|
|
5
3
|
import type { Client } from "./client";
|
|
4
|
+
import { NewIncomingConnection } from "../packets";
|
|
6
5
|
declare class Receiver {
|
|
7
|
-
private readonly client;
|
|
8
|
-
private readonly socket;
|
|
9
6
|
private lastInputSequence;
|
|
10
7
|
private receivedFrameSequences;
|
|
11
8
|
private lostFrameSequences;
|
|
@@ -13,26 +10,23 @@ declare class Receiver {
|
|
|
13
10
|
private inputOrderIndex;
|
|
14
11
|
protected inputOrderingQueue: Map<number, Map<number, Frame>>;
|
|
15
12
|
protected readonly fragmentsQueue: Map<number, Map<number, Frame>>;
|
|
16
|
-
|
|
13
|
+
private client;
|
|
14
|
+
constructor(client: Client);
|
|
15
|
+
incomingMessage(buffer: Buffer): void;
|
|
16
|
+
otherPackets(buffer: Buffer): void;
|
|
17
|
+
sendUnconnectedPing(): void;
|
|
17
18
|
private tick;
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
send(buffer: Buffer): void;
|
|
20
|
+
handleFrameSet(buffer: Buffer): void;
|
|
20
21
|
private handleFrame;
|
|
21
|
-
private
|
|
22
|
-
private processOrderedFrames;
|
|
23
|
-
private handleSequenced;
|
|
22
|
+
private processFrame;
|
|
24
23
|
private handleFragment;
|
|
25
24
|
private reassembleAndProcessFragment;
|
|
26
|
-
private
|
|
25
|
+
private handleSequenced;
|
|
26
|
+
private handleOrdered;
|
|
27
|
+
private processOrderedFrames;
|
|
27
28
|
private handleConnectedPing;
|
|
28
|
-
|
|
29
|
-
private handleNackSequences;
|
|
30
|
-
private handleUnconnectedPong;
|
|
31
|
-
private handleOpenConnectionReply1;
|
|
32
|
-
private handleOpenConnectionReply2;
|
|
33
|
-
private handleValidPacket;
|
|
34
|
-
private handleSequenceGap;
|
|
35
|
-
private createReassembledFrame;
|
|
29
|
+
handleConnectionRequestAcceptedTwo(frame: Frame): NewIncomingConnection;
|
|
36
30
|
private handleConnectionRequestAccepted;
|
|
37
31
|
}
|
|
38
32
|
export { Receiver };
|
package/dist/client/receiver.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Receiver = void 0;
|
|
4
|
-
const binarystream_1 = require("@serenityjs/binarystream");
|
|
5
4
|
const raknet_1 = require("@serenityjs/raknet");
|
|
5
|
+
const binarystream_1 = require("@serenityjs/binarystream");
|
|
6
6
|
const packets_1 = require("../packets");
|
|
7
7
|
const sender_1 = require("./sender");
|
|
8
|
+
const magic = Buffer.from("00ffff00fefefefefdfdfdfd12345678", "hex");
|
|
8
9
|
class Receiver {
|
|
9
|
-
constructor(client
|
|
10
|
+
constructor(client) {
|
|
10
11
|
this.lastInputSequence = -1;
|
|
11
12
|
this.receivedFrameSequences = new Set();
|
|
12
13
|
this.lostFrameSequences = new Set();
|
|
@@ -15,55 +16,98 @@ class Receiver {
|
|
|
15
16
|
this.inputOrderingQueue = new Map();
|
|
16
17
|
this.fragmentsQueue = new Map();
|
|
17
18
|
this.client = client;
|
|
18
|
-
this.client.on("tick", () => this.tick());
|
|
19
|
-
this.socket = socket;
|
|
20
|
-
this.socket.on("message", (packet) => this.handle(packet));
|
|
21
19
|
for (let index = 0; index < 64; index++) {
|
|
22
20
|
this.inputOrderingQueue.set(index, new Map());
|
|
23
21
|
}
|
|
22
|
+
this.client.on("tick", () => {
|
|
23
|
+
this.tick();
|
|
24
|
+
});
|
|
25
|
+
this.client.socket.on("message", (...data) => {
|
|
26
|
+
this.incomingMessage(data[0]);
|
|
27
|
+
});
|
|
24
28
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
case raknet_1.Packet.UnconnectedPong:
|
|
35
|
-
this.handleUnconnectedPong(packet);
|
|
29
|
+
incomingMessage(buffer) {
|
|
30
|
+
const packetId = buffer.readUint8();
|
|
31
|
+
const ignore = [132, 192, 128];
|
|
32
|
+
if (this.client.options.debug && !ignore.includes(packetId)) {
|
|
33
|
+
console.log(`Received Socket Message: ${packetId}`);
|
|
34
|
+
}
|
|
35
|
+
switch (packetId) {
|
|
36
|
+
case raknet_1.Bitflags.Valid:
|
|
37
|
+
this.handleFrameSet(buffer);
|
|
36
38
|
break;
|
|
37
|
-
case raknet_1.Packet.OpenConnectionReply1:
|
|
38
|
-
|
|
39
|
+
case raknet_1.Packet.OpenConnectionReply1: {
|
|
40
|
+
const reply = new packets_1.OpenConnectionReplyOne(buffer);
|
|
41
|
+
const deserialized = reply.deserialize();
|
|
42
|
+
if (reply.security) {
|
|
43
|
+
console.error("Server requires security, which is not supported.");
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
this.client.emit("open-connection-reply-one", deserialized);
|
|
47
|
+
sender_1.Sender.secondRequest(this.client, deserialized);
|
|
39
48
|
break;
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
}
|
|
50
|
+
case raknet_1.Packet.OpenConnectionReply2: {
|
|
51
|
+
const reply = new packets_1.OpenConnectionReplyTwo(buffer);
|
|
52
|
+
const deserialized = reply.deserialize();
|
|
53
|
+
this.client.emit("open-connection-reply-two", deserialized);
|
|
54
|
+
this.client.sender.connectionRequest();
|
|
42
55
|
break;
|
|
43
|
-
case raknet_1.Bitflags.Valid: {
|
|
44
|
-
if (this.client.options.debug)
|
|
45
|
-
console.log(`Received valid packet: ${packetType}`);
|
|
46
|
-
this.handleValidPacket(packet);
|
|
47
|
-
return;
|
|
48
56
|
}
|
|
49
|
-
case raknet_1.Packet.
|
|
50
|
-
this.client.emit("ack", new raknet_1.Ack(packet).deserialize());
|
|
57
|
+
case raknet_1.Packet.UnconnectedPong: {
|
|
51
58
|
break;
|
|
52
59
|
}
|
|
53
|
-
default:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
default:
|
|
61
|
+
this.otherPackets(buffer);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
otherPackets(buffer) {
|
|
65
|
+
const packetId = buffer.readUint8() & 0xf0;
|
|
66
|
+
switch (packetId) {
|
|
67
|
+
case raknet_1.Bitflags.Valid:
|
|
68
|
+
this.handleFrameSet(buffer);
|
|
69
|
+
break;
|
|
70
|
+
case raknet_1.Packet.Ack:
|
|
71
|
+
//this.ack(buffer);
|
|
72
|
+
break;
|
|
73
|
+
case raknet_1.Packet.Nack:
|
|
74
|
+
//console.debug(new Nack(buffer).deserialize());
|
|
75
|
+
break;
|
|
76
|
+
case raknet_1.Packet.ConnectionRequestAccepted: {
|
|
63
77
|
break;
|
|
64
78
|
}
|
|
79
|
+
default:
|
|
80
|
+
if (this.client.options.debug)
|
|
81
|
+
console.debug(`Received unknown packet ${packetId}`);
|
|
82
|
+
break;
|
|
65
83
|
}
|
|
66
84
|
}
|
|
85
|
+
sendUnconnectedPing() {
|
|
86
|
+
const packet = new raknet_1.UnconnectedPing();
|
|
87
|
+
packet.timestamp = BigInt(Date.now());
|
|
88
|
+
packet.magic = magic;
|
|
89
|
+
packet.client = BigInt(this.client.options.guid);
|
|
90
|
+
this.client.send(packet.serialize());
|
|
91
|
+
}
|
|
92
|
+
tick() {
|
|
93
|
+
if (this.receivedFrameSequences.size > 0) {
|
|
94
|
+
const ack = new raknet_1.Ack();
|
|
95
|
+
ack.sequences = [...this.receivedFrameSequences];
|
|
96
|
+
for (const sequence of this.receivedFrameSequences)
|
|
97
|
+
this.receivedFrameSequences.delete(sequence);
|
|
98
|
+
this.send(ack.serialize());
|
|
99
|
+
}
|
|
100
|
+
if (this.lostFrameSequences.size > 0) {
|
|
101
|
+
const nack = new raknet_1.Nack();
|
|
102
|
+
nack.sequences = [...this.lostFrameSequences];
|
|
103
|
+
for (const sequence of this.lostFrameSequences)
|
|
104
|
+
this.lostFrameSequences.delete(sequence);
|
|
105
|
+
this.send(nack.serialize());
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
send(buffer) {
|
|
109
|
+
this.client.send(buffer);
|
|
110
|
+
}
|
|
67
111
|
handleFrameSet(buffer) {
|
|
68
112
|
const frameSet = new raknet_1.FrameSet(buffer).deserialize();
|
|
69
113
|
if (this.receivedFrameSequences.has(frameSet.sequence)) {
|
|
@@ -72,22 +116,27 @@ class Receiver {
|
|
|
72
116
|
return;
|
|
73
117
|
}
|
|
74
118
|
this.lostFrameSequences.delete(frameSet.sequence);
|
|
75
|
-
if (frameSet.sequence
|
|
119
|
+
if (frameSet.sequence < this.lastInputSequence ||
|
|
120
|
+
frameSet.sequence === this.lastInputSequence) {
|
|
76
121
|
if (this.client.options.debug)
|
|
77
122
|
console.debug(`Received out of order frameset ${frameSet.sequence}!`);
|
|
78
123
|
return;
|
|
79
124
|
}
|
|
80
125
|
this.receivedFrameSequences.add(frameSet.sequence);
|
|
81
|
-
|
|
126
|
+
const diff = frameSet.sequence - this.lastInputSequence;
|
|
127
|
+
if (diff !== 1) {
|
|
128
|
+
for (let index = this.lastInputSequence + 1; index < frameSet.sequence; index++) {
|
|
129
|
+
if (!this.receivedFrameSequences.has(index)) {
|
|
130
|
+
this.lostFrameSequences.add(index);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
82
134
|
this.lastInputSequence = frameSet.sequence;
|
|
83
135
|
for (const frame of frameSet.frames) {
|
|
84
136
|
this.handleFrame(frame);
|
|
85
137
|
}
|
|
86
138
|
}
|
|
87
139
|
handleFrame(frame) {
|
|
88
|
-
if (this.client.options.debug) {
|
|
89
|
-
console.debug(`Handling frame: reliability=${frame.reliability}, orderIndex=${frame.orderIndex}, sequenceIndex=${frame.sequenceIndex}`);
|
|
90
|
-
}
|
|
91
140
|
if (frame.isSplit()) {
|
|
92
141
|
this.handleFragment(frame);
|
|
93
142
|
}
|
|
@@ -101,47 +150,31 @@ class Receiver {
|
|
|
101
150
|
this.processFrame(frame);
|
|
102
151
|
}
|
|
103
152
|
}
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
this.processFrame(frame);
|
|
117
|
-
this.inputOrderIndex[frame.orderChannel]++;
|
|
118
|
-
let nextOrderIndex = this.inputOrderIndex[frame.orderChannel];
|
|
119
|
-
while (orderingQueue.has(nextOrderIndex)) {
|
|
120
|
-
const nextFrame = orderingQueue.get(nextOrderIndex);
|
|
121
|
-
if (nextFrame) {
|
|
122
|
-
this.processFrame(nextFrame);
|
|
123
|
-
orderingQueue.delete(nextOrderIndex);
|
|
124
|
-
this.inputOrderIndex[frame.orderChannel]++;
|
|
125
|
-
nextOrderIndex++;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
handleSequenced(frame) {
|
|
130
|
-
const currentHighestSequence = this.inputHighestSequenceIndex[frame.orderChannel];
|
|
131
|
-
if (frame.sequenceIndex > currentHighestSequence) {
|
|
132
|
-
this.inputHighestSequenceIndex[frame.orderChannel] = frame.sequenceIndex;
|
|
133
|
-
this.processFrame(frame);
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
if (this.client.options.debug)
|
|
137
|
-
console.debug(`Discarding old sequenced frame: ${frame.sequenceIndex}`);
|
|
153
|
+
processFrame(frame) {
|
|
154
|
+
const header = frame.payload[0];
|
|
155
|
+
switch (header) {
|
|
156
|
+
case raknet_1.Packet.ConnectionRequestAccepted:
|
|
157
|
+
this.handleConnectionRequestAccepted(frame);
|
|
158
|
+
break;
|
|
159
|
+
case raknet_1.Packet.ConnectedPing:
|
|
160
|
+
this.handleConnectedPing(frame.payload);
|
|
161
|
+
break;
|
|
162
|
+
default:
|
|
163
|
+
this.client.emit("encapsulated", frame);
|
|
164
|
+
break;
|
|
138
165
|
}
|
|
139
166
|
}
|
|
140
167
|
handleFragment(frame) {
|
|
141
|
-
|
|
142
|
-
|
|
168
|
+
if (!this.fragmentsQueue.has(frame.splitId)) {
|
|
169
|
+
this.fragmentsQueue.set(frame.splitId, new Map());
|
|
170
|
+
}
|
|
171
|
+
const fragment = this.fragmentsQueue.get(frame.splitId);
|
|
172
|
+
if (!fragment)
|
|
173
|
+
return;
|
|
143
174
|
fragment.set(frame.splitIndex, frame);
|
|
144
175
|
if (fragment.size === frame.splitSize) {
|
|
176
|
+
if (this.client.options.debug)
|
|
177
|
+
console.debug(`Reassembling complete frame from fragments: splitId=${frame.splitId}`);
|
|
145
178
|
this.reassembleAndProcessFragment(frame, fragment);
|
|
146
179
|
}
|
|
147
180
|
}
|
|
@@ -157,119 +190,114 @@ class Receiver {
|
|
|
157
190
|
return;
|
|
158
191
|
}
|
|
159
192
|
}
|
|
160
|
-
const reassembledFrame =
|
|
193
|
+
const reassembledFrame = new raknet_1.Frame();
|
|
194
|
+
reassembledFrame.reliability = frame.reliability;
|
|
195
|
+
reassembledFrame.reliableIndex = frame.reliableIndex;
|
|
196
|
+
reassembledFrame.sequenceIndex = frame.sequenceIndex;
|
|
197
|
+
reassembledFrame.orderIndex = frame.orderIndex;
|
|
198
|
+
reassembledFrame.orderChannel = frame.orderChannel;
|
|
199
|
+
reassembledFrame.payload = stream.getBuffer();
|
|
161
200
|
this.fragmentsQueue.delete(frame.splitId);
|
|
162
201
|
this.handleFrame(reassembledFrame);
|
|
163
202
|
}
|
|
164
|
-
|
|
165
|
-
const
|
|
203
|
+
handleSequenced(frame) {
|
|
204
|
+
const currentHighestSequence = this.inputHighestSequenceIndex[frame.orderChannel];
|
|
166
205
|
if (this.client.options.debug)
|
|
167
|
-
console.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
206
|
+
console.debug(`Handling sequenced frame: sequenceIndex=${frame.sequenceIndex}, currentHighest=${currentHighestSequence}`);
|
|
207
|
+
if (frame.sequenceIndex > currentHighestSequence) {
|
|
208
|
+
this.inputHighestSequenceIndex[frame.orderChannel] = frame.sequenceIndex;
|
|
209
|
+
this.processFrame(frame);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
if (this.client.options.debug)
|
|
213
|
+
console.debug(`Discarding old sequenced frame: ${frame.sequenceIndex}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
handleOrdered(frame) {
|
|
217
|
+
if (this.client.options.debug)
|
|
218
|
+
console.debug(`Handling ordered frame: orderIndex=${frame.orderIndex}, channel=${frame.orderChannel}`);
|
|
219
|
+
const expectedOrderIndex = this.inputOrderIndex[frame.orderChannel];
|
|
220
|
+
const outOfOrderQueue = this.inputOrderingQueue.get(frame.orderChannel);
|
|
221
|
+
if (frame.orderIndex === expectedOrderIndex) {
|
|
222
|
+
this.processOrderedFrames(frame, outOfOrderQueue);
|
|
223
|
+
}
|
|
224
|
+
else if (frame.orderIndex > expectedOrderIndex) {
|
|
225
|
+
if (this.client.options.debug)
|
|
226
|
+
console.debug(`Queuing out-of-order frame: ${frame.orderIndex}`);
|
|
227
|
+
outOfOrderQueue.set(frame.orderIndex, frame);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
if (this.client.options.debug)
|
|
231
|
+
console.debug(`Discarding old frame: ${frame.orderIndex}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
processOrderedFrames(frame, outOfOrderQueue) {
|
|
235
|
+
this.processFrame(frame);
|
|
236
|
+
this.inputOrderIndex[frame.orderChannel]++;
|
|
237
|
+
let nextOrderIndex = this.inputOrderIndex[frame.orderChannel];
|
|
238
|
+
while (outOfOrderQueue.has(nextOrderIndex)) {
|
|
239
|
+
const nextFrame = outOfOrderQueue.get(nextOrderIndex);
|
|
240
|
+
if (nextFrame) {
|
|
188
241
|
if (this.client.options.debug)
|
|
189
|
-
console.debug(`
|
|
190
|
-
|
|
242
|
+
console.debug(`Processing queued frame: ${nextOrderIndex}`);
|
|
243
|
+
this.processFrame(nextFrame);
|
|
244
|
+
outOfOrderQueue.delete(nextOrderIndex);
|
|
245
|
+
this.inputOrderIndex[frame.orderChannel]++;
|
|
246
|
+
nextOrderIndex++;
|
|
191
247
|
}
|
|
192
248
|
}
|
|
193
249
|
}
|
|
194
|
-
handleConnectedPing(
|
|
195
|
-
const packet = new packets_1.ConnectedPing(
|
|
250
|
+
handleConnectedPing(buffer) {
|
|
251
|
+
const packet = new packets_1.ConnectedPing(buffer);
|
|
196
252
|
const deserializedPacket = packet.deserialize();
|
|
197
|
-
const pong = new
|
|
198
|
-
pong.
|
|
199
|
-
pong.
|
|
253
|
+
const pong = new packets_1.ConnectedPong();
|
|
254
|
+
pong.pingTime = deserializedPacket.timestamp;
|
|
255
|
+
pong.pongTime = BigInt(Date.now());
|
|
200
256
|
const frame = new raknet_1.Frame();
|
|
201
257
|
frame.reliability = raknet_1.Reliability.Unreliable;
|
|
202
258
|
frame.orderChannel = 0;
|
|
203
259
|
frame.payload = pong.serialize();
|
|
204
260
|
this.client.sender.sendFrame(frame, raknet_1.Priority.Immediate);
|
|
205
261
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
262
|
+
handleConnectionRequestAcceptedTwo(frame) {
|
|
263
|
+
const des = new packets_1.ConnectionRequestAccepted(frame.payload).deserialize();
|
|
264
|
+
const packet = new packets_1.NewIncomingConnection();
|
|
265
|
+
packet.internalAddresses = new Array(10).fill(new raknet_1.Address("0.0.0.0", 0, 4));
|
|
266
|
+
packet.serverAddress = des.address;
|
|
267
|
+
packet.incomingTimestamp = BigInt(Date.now());
|
|
268
|
+
packet.serverTimestamp = des.timestamp;
|
|
269
|
+
return packet;
|
|
213
270
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
nack.sequences = [...this.lostFrameSequences];
|
|
218
|
-
this.lostFrameSequences.clear();
|
|
219
|
-
this.client.send(nack.serialize());
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
handleUnconnectedPong(packet) {
|
|
223
|
-
const pong = new packets_1.UnconnectedPong(packet);
|
|
224
|
-
this.client.emit("unconnected-pong", pong.deserialize());
|
|
225
|
-
}
|
|
226
|
-
handleOpenConnectionReply1(packet) {
|
|
227
|
-
const reply = new packets_1.OpenConnectionFirstReply(packet);
|
|
228
|
-
const deserialized = reply.deserialize();
|
|
229
|
-
this.client.emit("open-connection-first-reply", deserialized);
|
|
230
|
-
sender_1.Sender.secondRequest(this.client, deserialized);
|
|
231
|
-
}
|
|
232
|
-
handleOpenConnectionReply2(packet) {
|
|
233
|
-
const reply = new packets_1.OpenConnectionSecondReply(packet);
|
|
234
|
-
const deserialized = reply.deserialize();
|
|
235
|
-
this.client.emit("open-connection-second-reply", deserialized);
|
|
236
|
-
this.client.sender.connectionRequest();
|
|
237
|
-
}
|
|
238
|
-
handleValidPacket(packet) {
|
|
271
|
+
handleConnectionRequestAccepted(frame) {
|
|
272
|
+
let des;
|
|
273
|
+
let packet;
|
|
239
274
|
try {
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
275
|
+
const IncomingPacket = new packets_1.ConnectionRequestAccepted(frame.payload);
|
|
276
|
+
des = IncomingPacket.deserialize();
|
|
277
|
+
packet = new packets_1.NewIncomingConnection();
|
|
278
|
+
packet.internalAddresses = new Array(10).fill(new raknet_1.Address("0.0.0.0", 0, 4));
|
|
279
|
+
packet.serverAddress = new raknet_1.Address(des.address.address, des.address.port, 4);
|
|
280
|
+
packet.incomingTimestamp = BigInt(Date.now());
|
|
281
|
+
packet.serverTimestamp = des.timestamp;
|
|
244
282
|
}
|
|
245
283
|
catch (error) {
|
|
246
|
-
|
|
284
|
+
packet = this.handleConnectionRequestAcceptedTwo(frame);
|
|
247
285
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (diff !== 1) {
|
|
252
|
-
for (let index = this.lastInputSequence + 1; index < currentSequence; index++) {
|
|
253
|
-
if (!this.receivedFrameSequences.has(index)) {
|
|
254
|
-
this.lostFrameSequences.add(index);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
286
|
+
if (!packet) {
|
|
287
|
+
console.error("Failed to deserialize IncomingPacket!");
|
|
288
|
+
return;
|
|
257
289
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
handleConnectionRequestAccepted(frame) {
|
|
270
|
-
const packet = new packets_1.ConnectionRequestAccepted(frame.payload);
|
|
271
|
-
const deserialized = packet.deserialize();
|
|
272
|
-
this.client.sender.newIncommingConnection(frame.payload, deserialized);
|
|
290
|
+
const sendFrame = new raknet_1.Frame();
|
|
291
|
+
sendFrame.reliability = raknet_1.Reliability.ReliableOrdered;
|
|
292
|
+
sendFrame.orderChannel = 0;
|
|
293
|
+
sendFrame.payload = packet.serialize();
|
|
294
|
+
if (!sendFrame.payload) {
|
|
295
|
+
console.error("Failed to serialize the packet!");
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
this.client.status = raknet_1.Status.Connected;
|
|
299
|
+
this.client.sender.sendFrame(sendFrame, raknet_1.Priority.Immediate);
|
|
300
|
+
void this.client.emit("connect");
|
|
273
301
|
}
|
|
274
302
|
}
|
|
275
303
|
exports.Receiver = Receiver;
|
package/dist/client/sender.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Frame, FrameSet, Priority } from "@serenityjs/raknet";
|
|
3
3
|
import type { Client } from "./client";
|
|
4
|
-
import {
|
|
4
|
+
import { OpenConnectionReplyOne } from "../packets";
|
|
5
5
|
import { type Advertisement } from "./types/Advertisement";
|
|
6
6
|
declare class Sender {
|
|
7
7
|
private readonly client;
|
|
@@ -22,9 +22,9 @@ declare class Sender {
|
|
|
22
22
|
private createSplitFrame;
|
|
23
23
|
private queueFrame;
|
|
24
24
|
sendQueue(amount: number): void;
|
|
25
|
-
newIncommingConnection(payload: Buffer
|
|
25
|
+
newIncommingConnection(payload: Buffer): void;
|
|
26
26
|
connectionRequest(): void;
|
|
27
|
-
static secondRequest(client: Client, reply1:
|
|
27
|
+
static secondRequest(client: Client, reply1: OpenConnectionReplyOne): void;
|
|
28
28
|
static ping(client: Client): Promise<Advertisement>;
|
|
29
29
|
static connect(client: Client): Promise<void>;
|
|
30
30
|
}
|
package/dist/client/sender.js
CHANGED
|
@@ -12,17 +12,19 @@ class Sender {
|
|
|
12
12
|
this.outputReliableIndex = 0;
|
|
13
13
|
this.outputFrames = new Set();
|
|
14
14
|
this.outputBackup = new Map();
|
|
15
|
-
this.outputOrderIndex = Array(32).fill(0);
|
|
16
|
-
this.outputSequenceIndex = Array(32).fill(0);
|
|
17
15
|
this.outputFrameQueue = new raknet_1.FrameSet();
|
|
18
|
-
this.mtu = client.options.mtu;
|
|
19
16
|
this.outputFrameQueue.frames = [];
|
|
17
|
+
this.outputOrderIndex = Array.from({ length: 32 }).fill(0);
|
|
18
|
+
this.outputSequenceIndex = Array.from({ length: 32 }).fill(0);
|
|
19
|
+
this.mtu = client.options.mtu;
|
|
20
20
|
this.client.on("tick", () => this.tick());
|
|
21
21
|
}
|
|
22
22
|
tick() {
|
|
23
23
|
if (this.client.status === raknet_1.Status.Disconnecting ||
|
|
24
|
-
this.client.status === raknet_1.Status.Disconnected)
|
|
24
|
+
this.client.status === raknet_1.Status.Disconnected) {
|
|
25
|
+
console.log("Can not send queue, client is disconnecting or disconnected");
|
|
25
26
|
return;
|
|
27
|
+
}
|
|
26
28
|
this.sendQueue(this.outputFrames.size);
|
|
27
29
|
}
|
|
28
30
|
sendFrame(frame, priority) {
|
|
@@ -98,40 +100,50 @@ class Sender {
|
|
|
98
100
|
this.outputFrames.delete(frame);
|
|
99
101
|
this.client.send(frameset.serialize());
|
|
100
102
|
}
|
|
101
|
-
newIncommingConnection(payload
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
newIncommingConnection(payload) {
|
|
104
|
+
let des = null;
|
|
105
|
+
let packet;
|
|
106
|
+
console.log("RATATA");
|
|
107
|
+
try {
|
|
108
|
+
const IncomingPacket = new packets_1.ConnectionRequestAccepted(payload);
|
|
109
|
+
des = IncomingPacket.deserialize();
|
|
110
|
+
packet = new packets_1.NewIncomingConnection();
|
|
104
111
|
packet.internalAddresses = new Array(10).fill(new raknet_1.Address("0.0.0.0", 0, 4));
|
|
105
|
-
packet.serverAddress = new raknet_1.Address(
|
|
112
|
+
packet.serverAddress = new raknet_1.Address(des.address.address, des.address.port, 4);
|
|
106
113
|
packet.incomingTimestamp = BigInt(Date.now());
|
|
107
|
-
packet.serverTimestamp =
|
|
114
|
+
packet.serverTimestamp = des.timestamp;
|
|
108
115
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
packet
|
|
116
|
+
catch (error) {
|
|
117
|
+
const _des = new packets_1.ConnectionRequestAccepted(payload).deserialize();
|
|
118
|
+
packet = new packets_1.NewIncomingConnection();
|
|
119
|
+
packet.internalAddresses = new Array(20).fill(new raknet_1.Address("0.0.0.0", 0, 4));
|
|
120
|
+
packet.serverAddress = new raknet_1.Address("0.0.0.0", 0, 4);
|
|
112
121
|
packet.incomingTimestamp = BigInt(Date.now());
|
|
113
|
-
packet.serverTimestamp =
|
|
122
|
+
packet.serverTimestamp = BigInt(0);
|
|
114
123
|
}
|
|
124
|
+
if (!packet) {
|
|
125
|
+
console.error("Failed to deserialize IncomingPacket!");
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
console.log(packet);
|
|
129
|
+
this.client.status = raknet_1.Status.Connected;
|
|
115
130
|
this.client.sender.frameAndSend(packet.serialize(), raknet_1.Priority.Immediate);
|
|
131
|
+
void this.client.emit("connect");
|
|
116
132
|
}
|
|
117
133
|
connectionRequest() {
|
|
118
134
|
const packet = new packets_1.ConnectionRequest();
|
|
119
135
|
packet.client = BigInt(this.client.options.guid);
|
|
120
136
|
packet.timestamp = BigInt(Date.now());
|
|
121
137
|
packet.security = false;
|
|
122
|
-
|
|
123
|
-
frame.reliability = raknet_1.Reliability.Reliable;
|
|
124
|
-
frame.orderChannel = 0;
|
|
125
|
-
frame.payload = packet.serialize();
|
|
126
|
-
this.sendFrame(frame, raknet_1.Priority.Immediate);
|
|
138
|
+
this.frameAndSend(packet.serialize(), raknet_1.Priority.Immediate);
|
|
127
139
|
}
|
|
128
140
|
static secondRequest(client, reply1) {
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
client.send(
|
|
141
|
+
const pak = new packets_1.OpenConnectionRequestTwo();
|
|
142
|
+
pak.magic = reply1.magic;
|
|
143
|
+
pak.address = new raknet_1.Address("0.0.0.0", client.options.port, 4);
|
|
144
|
+
pak.mtu = reply1.mtu;
|
|
145
|
+
pak.client = client.options.guid;
|
|
146
|
+
client.send(pak.serialize());
|
|
135
147
|
}
|
|
136
148
|
static async ping(client) {
|
|
137
149
|
return new Promise((resolve, reject) => {
|
|
@@ -156,26 +168,76 @@ class Sender {
|
|
|
156
168
|
});
|
|
157
169
|
}
|
|
158
170
|
static async connect(client) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
const maxRetries = 5;
|
|
172
|
+
let retryCount = 0;
|
|
173
|
+
const attemptConnection = () => {
|
|
174
|
+
return new Promise((resolve, reject) => {
|
|
175
|
+
let send = true;
|
|
176
|
+
let MTU = client.options.mtu - 28;
|
|
177
|
+
const packet = new packets_1.OpenConnectionRequestOne();
|
|
178
|
+
packet.magic = Buffer.from([
|
|
179
|
+
0, 255, 255, 0, 254, 254, 254, 254, 253, 253, 253, 253, 18, 52, 86,
|
|
180
|
+
120,
|
|
181
|
+
]);
|
|
182
|
+
packet.mtu = MTU;
|
|
183
|
+
packet.protocol = client.options.protocol;
|
|
184
|
+
const interval = setInterval(() => {
|
|
185
|
+
if (MTU <= 1172)
|
|
186
|
+
MTU = 548;
|
|
187
|
+
if (MTU > 1400)
|
|
188
|
+
MTU = 1172;
|
|
189
|
+
packet.mtu = MTU;
|
|
190
|
+
client.options.mtu = MTU;
|
|
191
|
+
if (send) {
|
|
192
|
+
client.send(packet.serialize());
|
|
193
|
+
}
|
|
194
|
+
}, 1500);
|
|
195
|
+
const timer = setTimeout(() => {
|
|
196
|
+
client.socket.off("message", listener);
|
|
197
|
+
clearTimeout(timer);
|
|
198
|
+
clearInterval(interval);
|
|
199
|
+
reject(new Error("Connection attempt timed out"));
|
|
200
|
+
}, client.options.timeout);
|
|
201
|
+
const packet8Timer = setTimeout(() => {
|
|
172
202
|
client.socket.off("message", listener);
|
|
173
203
|
clearTimeout(timer);
|
|
174
|
-
|
|
204
|
+
clearInterval(interval);
|
|
205
|
+
reject(new Error("Packet 8 not received"));
|
|
206
|
+
}, client.options.timeout / 3);
|
|
207
|
+
const listener = (buffer) => {
|
|
208
|
+
if (buffer[0] === raknet_1.Packet.OpenConnectionReply1) {
|
|
209
|
+
send = false;
|
|
210
|
+
const reply1 = new packets_1.OpenConnectionReplyOne(buffer);
|
|
211
|
+
const deserializedReply1 = reply1.deserialize();
|
|
212
|
+
Sender.secondRequest(client, deserializedReply1);
|
|
213
|
+
}
|
|
214
|
+
else if (buffer[0] === raknet_1.Packet.Ack) {
|
|
215
|
+
client.socket.off("message", listener);
|
|
216
|
+
clearTimeout(timer);
|
|
217
|
+
clearTimeout(packet8Timer);
|
|
218
|
+
clearInterval(interval);
|
|
219
|
+
resolve();
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
client.socket.on("message", listener);
|
|
223
|
+
client.send(packet.serialize());
|
|
224
|
+
});
|
|
225
|
+
};
|
|
226
|
+
while (retryCount < maxRetries) {
|
|
227
|
+
try {
|
|
228
|
+
await attemptConnection();
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
if (client.options.debug)
|
|
233
|
+
console.log(`Connection attempt ${retryCount + 1} failed: ${error.message}`);
|
|
234
|
+
retryCount++;
|
|
235
|
+
if (retryCount >= maxRetries) {
|
|
236
|
+
throw new Error(`Failed to connect after ${maxRetries} attempts`);
|
|
175
237
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
238
|
+
await new Promise((resolve) => setTimeout(resolve, 2000));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
179
241
|
}
|
|
180
242
|
}
|
|
181
243
|
exports.Sender = Sender;
|
|
@@ -9,28 +9,28 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.OpenConnectionReplyOne = void 0;
|
|
13
13
|
const binarystream_1 = require("@serenityjs/binarystream");
|
|
14
14
|
const raknet_1 = require("@serenityjs/raknet");
|
|
15
|
-
let
|
|
15
|
+
let OpenConnectionReplyOne = class OpenConnectionReplyOne extends raknet_1.BasePacket {
|
|
16
16
|
};
|
|
17
|
-
exports.
|
|
17
|
+
exports.OpenConnectionReplyOne = OpenConnectionReplyOne;
|
|
18
18
|
__decorate([
|
|
19
19
|
(0, raknet_1.Serialize)(raknet_1.Magic),
|
|
20
|
-
__metadata("design:type",
|
|
21
|
-
],
|
|
20
|
+
__metadata("design:type", Buffer)
|
|
21
|
+
], OpenConnectionReplyOne.prototype, "magic", void 0);
|
|
22
22
|
__decorate([
|
|
23
|
-
(0, raknet_1.Serialize)(binarystream_1.
|
|
23
|
+
(0, raknet_1.Serialize)(binarystream_1.Uint64, 0 /* Endianness.Big */),
|
|
24
24
|
__metadata("design:type", BigInt)
|
|
25
|
-
],
|
|
25
|
+
], OpenConnectionReplyOne.prototype, "guid", void 0);
|
|
26
26
|
__decorate([
|
|
27
27
|
(0, raknet_1.Serialize)(binarystream_1.Bool),
|
|
28
28
|
__metadata("design:type", Boolean)
|
|
29
|
-
],
|
|
29
|
+
], OpenConnectionReplyOne.prototype, "security", void 0);
|
|
30
30
|
__decorate([
|
|
31
|
-
(0, raknet_1.Serialize)(binarystream_1.
|
|
31
|
+
(0, raknet_1.Serialize)(binarystream_1.Uint16, 0 /* Endianness.Big */),
|
|
32
32
|
__metadata("design:type", Number)
|
|
33
|
-
],
|
|
34
|
-
exports.
|
|
33
|
+
], OpenConnectionReplyOne.prototype, "mtu", void 0);
|
|
34
|
+
exports.OpenConnectionReplyOne = OpenConnectionReplyOne = __decorate([
|
|
35
35
|
(0, raknet_1.Proto)(raknet_1.Packet.OpenConnectionReply1)
|
|
36
|
-
],
|
|
36
|
+
], OpenConnectionReplyOne);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Address, BasePacket, Magic } from "@serenityjs/raknet";
|
|
2
|
-
declare class
|
|
2
|
+
declare class OpenConnectionReplyTwo extends BasePacket {
|
|
3
3
|
magic: Magic;
|
|
4
4
|
guid: bigint;
|
|
5
5
|
address: Address;
|
|
6
6
|
mtu: number;
|
|
7
7
|
encryption: boolean;
|
|
8
8
|
}
|
|
9
|
-
export {
|
|
9
|
+
export { OpenConnectionReplyTwo };
|
|
@@ -9,32 +9,32 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.OpenConnectionReplyTwo = void 0;
|
|
13
13
|
const binarystream_1 = require("@serenityjs/binarystream");
|
|
14
14
|
const raknet_1 = require("@serenityjs/raknet");
|
|
15
|
-
let
|
|
15
|
+
let OpenConnectionReplyTwo = class OpenConnectionReplyTwo extends raknet_1.BasePacket {
|
|
16
16
|
};
|
|
17
|
-
exports.
|
|
17
|
+
exports.OpenConnectionReplyTwo = OpenConnectionReplyTwo;
|
|
18
18
|
__decorate([
|
|
19
19
|
(0, raknet_1.Serialize)(raknet_1.Magic),
|
|
20
20
|
__metadata("design:type", raknet_1.Magic)
|
|
21
|
-
],
|
|
21
|
+
], OpenConnectionReplyTwo.prototype, "magic", void 0);
|
|
22
22
|
__decorate([
|
|
23
23
|
(0, raknet_1.Serialize)(binarystream_1.Long),
|
|
24
24
|
__metadata("design:type", BigInt)
|
|
25
|
-
],
|
|
25
|
+
], OpenConnectionReplyTwo.prototype, "guid", void 0);
|
|
26
26
|
__decorate([
|
|
27
27
|
(0, raknet_1.Serialize)(raknet_1.Address),
|
|
28
28
|
__metadata("design:type", raknet_1.Address)
|
|
29
|
-
],
|
|
29
|
+
], OpenConnectionReplyTwo.prototype, "address", void 0);
|
|
30
30
|
__decorate([
|
|
31
31
|
(0, raknet_1.Serialize)(binarystream_1.Short),
|
|
32
32
|
__metadata("design:type", Number)
|
|
33
|
-
],
|
|
33
|
+
], OpenConnectionReplyTwo.prototype, "mtu", void 0);
|
|
34
34
|
__decorate([
|
|
35
35
|
(0, raknet_1.Serialize)(binarystream_1.Bool),
|
|
36
36
|
__metadata("design:type", Boolean)
|
|
37
|
-
],
|
|
38
|
-
exports.
|
|
37
|
+
], OpenConnectionReplyTwo.prototype, "encryption", void 0);
|
|
38
|
+
exports.OpenConnectionReplyTwo = OpenConnectionReplyTwo = __decorate([
|
|
39
39
|
(0, raknet_1.Proto)(raknet_1.Packet.OpenConnectionReply2)
|
|
40
|
-
],
|
|
40
|
+
], OpenConnectionReplyTwo);
|
|
@@ -9,24 +9,24 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.OpenConnectionRequestOne = void 0;
|
|
13
13
|
const binarystream_1 = require("@serenityjs/binarystream");
|
|
14
14
|
const raknet_1 = require("@serenityjs/raknet");
|
|
15
|
-
let
|
|
15
|
+
let OpenConnectionRequestOne = class OpenConnectionRequestOne extends raknet_1.BasePacket {
|
|
16
16
|
};
|
|
17
|
-
exports.
|
|
17
|
+
exports.OpenConnectionRequestOne = OpenConnectionRequestOne;
|
|
18
18
|
__decorate([
|
|
19
19
|
(0, raknet_1.Serialize)(raknet_1.Magic),
|
|
20
|
-
__metadata("design:type",
|
|
21
|
-
],
|
|
20
|
+
__metadata("design:type", Buffer)
|
|
21
|
+
], OpenConnectionRequestOne.prototype, "magic", void 0);
|
|
22
22
|
__decorate([
|
|
23
23
|
(0, raknet_1.Serialize)(binarystream_1.Uint8),
|
|
24
24
|
__metadata("design:type", Number)
|
|
25
|
-
],
|
|
25
|
+
], OpenConnectionRequestOne.prototype, "protocol", void 0);
|
|
26
26
|
__decorate([
|
|
27
27
|
(0, raknet_1.Serialize)(raknet_1.MTU),
|
|
28
28
|
__metadata("design:type", Number)
|
|
29
|
-
],
|
|
30
|
-
exports.
|
|
29
|
+
], OpenConnectionRequestOne.prototype, "mtu", void 0);
|
|
30
|
+
exports.OpenConnectionRequestOne = OpenConnectionRequestOne = __decorate([
|
|
31
31
|
(0, raknet_1.Proto)(raknet_1.Packet.OpenConnectionRequest1)
|
|
32
|
-
],
|
|
32
|
+
], OpenConnectionRequestOne);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Address, BasePacket, Magic } from "@serenityjs/raknet";
|
|
2
|
-
declare class
|
|
2
|
+
declare class OpenConnectionRequestTwo extends BasePacket {
|
|
3
3
|
magic: Magic;
|
|
4
4
|
address: Address;
|
|
5
5
|
mtu: number;
|
|
6
6
|
client: bigint;
|
|
7
7
|
}
|
|
8
|
-
export {
|
|
8
|
+
export { OpenConnectionRequestTwo };
|
|
@@ -9,28 +9,28 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.OpenConnectionRequestTwo = void 0;
|
|
13
13
|
const binarystream_1 = require("@serenityjs/binarystream");
|
|
14
14
|
const raknet_1 = require("@serenityjs/raknet");
|
|
15
|
-
let
|
|
15
|
+
let OpenConnectionRequestTwo = class OpenConnectionRequestTwo extends raknet_1.BasePacket {
|
|
16
16
|
};
|
|
17
|
-
exports.
|
|
17
|
+
exports.OpenConnectionRequestTwo = OpenConnectionRequestTwo;
|
|
18
18
|
__decorate([
|
|
19
19
|
(0, raknet_1.Serialize)(raknet_1.Magic),
|
|
20
20
|
__metadata("design:type", raknet_1.Magic)
|
|
21
|
-
],
|
|
21
|
+
], OpenConnectionRequestTwo.prototype, "magic", void 0);
|
|
22
22
|
__decorate([
|
|
23
23
|
(0, raknet_1.Serialize)(raknet_1.Address),
|
|
24
24
|
__metadata("design:type", raknet_1.Address)
|
|
25
|
-
],
|
|
25
|
+
], OpenConnectionRequestTwo.prototype, "address", void 0);
|
|
26
26
|
__decorate([
|
|
27
|
-
(0, raknet_1.Serialize)(binarystream_1.
|
|
27
|
+
(0, raknet_1.Serialize)(binarystream_1.Uint16, 0 /* Endianness.Big */),
|
|
28
28
|
__metadata("design:type", Number)
|
|
29
|
-
],
|
|
29
|
+
], OpenConnectionRequestTwo.prototype, "mtu", void 0);
|
|
30
30
|
__decorate([
|
|
31
|
-
(0, raknet_1.Serialize)(binarystream_1.Long),
|
|
31
|
+
(0, raknet_1.Serialize)(binarystream_1.Long, 0 /* Endianness.Big */),
|
|
32
32
|
__metadata("design:type", BigInt)
|
|
33
|
-
],
|
|
34
|
-
exports.
|
|
33
|
+
], OpenConnectionRequestTwo.prototype, "client", void 0);
|
|
34
|
+
exports.OpenConnectionRequestTwo = OpenConnectionRequestTwo = __decorate([
|
|
35
35
|
(0, raknet_1.Proto)(raknet_1.Packet.OpenConnectionRequest2)
|
|
36
|
-
],
|
|
36
|
+
], OpenConnectionRequestTwo);
|
package/dist/packets/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ export * from "./connected-pong";
|
|
|
3
3
|
export * from "./connection-request-accepted";
|
|
4
4
|
export * from "./connection-request";
|
|
5
5
|
export * from "./new-incoming-connection";
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
6
|
+
export * from "./OpenConnectionReplyOne";
|
|
7
|
+
export * from "./OpenConnectionRequestOne";
|
|
8
|
+
export * from "./OpenConnectionReplyTwo";
|
|
9
|
+
export * from "./OpenConnectionRequestTwo";
|
|
10
10
|
export * from "./unconnected-ping";
|
|
11
11
|
export * from "./unconnected-pong";
|
|
12
12
|
export * from "./disconnect";
|
package/dist/packets/index.js
CHANGED
|
@@ -19,10 +19,10 @@ __exportStar(require("./connected-pong"), exports);
|
|
|
19
19
|
__exportStar(require("./connection-request-accepted"), exports);
|
|
20
20
|
__exportStar(require("./connection-request"), exports);
|
|
21
21
|
__exportStar(require("./new-incoming-connection"), exports);
|
|
22
|
-
__exportStar(require("./
|
|
23
|
-
__exportStar(require("./
|
|
24
|
-
__exportStar(require("./
|
|
25
|
-
__exportStar(require("./
|
|
22
|
+
__exportStar(require("./OpenConnectionReplyOne"), exports);
|
|
23
|
+
__exportStar(require("./OpenConnectionRequestOne"), exports);
|
|
24
|
+
__exportStar(require("./OpenConnectionReplyTwo"), exports);
|
|
25
|
+
__exportStar(require("./OpenConnectionRequestTwo"), exports);
|
|
26
26
|
__exportStar(require("./unconnected-ping"), exports);
|
|
27
27
|
__exportStar(require("./unconnected-pong"), exports);
|
|
28
28
|
__exportStar(require("./disconnect"), exports);
|
package/dist/tools/test.js
CHANGED
package/package.json
CHANGED