@sanctumterra/raknet 1.0.11 → 1.0.13

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/bun.lockb CHANGED
Binary file
@@ -1,5 +1,6 @@
1
1
  import { Frame } from "@serenityjs/raknet";
2
2
  import { RakNetClient } from "./RaknetClient";
3
+ import { OhMyNewIncommingConnection } from "../packets/raknet/OhMyNewIncommingConnection";
3
4
  export declare class FrameHandler {
4
5
  private lastInputSequence;
5
6
  private receivedFrameSequences;
@@ -21,5 +22,6 @@ export declare class FrameHandler {
21
22
  private handleOrdered;
22
23
  private processOrderedFrames;
23
24
  private handleConnectedPing;
25
+ handleConnectionRequestAcceptedTwo(frame: Frame): OhMyNewIncommingConnection;
24
26
  private handleConnectionRequestAccepted;
25
27
  }
@@ -12,6 +12,7 @@ const _raknet = require("@serenityjs/raknet");
12
12
  const _OhMyNewIncommingConnection = require("../packets/raknet/OhMyNewIncommingConnection");
13
13
  const _binarystream = require("@serenityjs/binarystream");
14
14
  const _Logger = require("../utils/Logger");
15
+ const _OhMyConnectionRequestAccepted = require("../packets/raknet/OhMyConnectionRequestAccepted");
15
16
  class FrameHandler {
16
17
  tick() {
17
18
  if (this.receivedFrameSequences.size > 0) {
@@ -168,21 +169,39 @@ class FrameHandler {
168
169
  frame.payload = pong.serialize();
169
170
  this.raknet.queue.sendFrame(frame, _raknet.Priority.Immediate);
170
171
  }
171
- handleConnectionRequestAccepted(frame) {
172
- const IncomingPacket = new _raknet.ConnectionRequestAccepted(frame.payload);
173
- const des = IncomingPacket.deserialize();
174
- if (!des) {
175
- console.error('Failed to deserialize IncomingPacket!');
176
- return;
177
- }
178
- const packet = new _OhMyNewIncommingConnection.OhMyNewIncommingConnection();
172
+ handleConnectionRequestAcceptedTwo(frame) {
173
+ let des = new _OhMyConnectionRequestAccepted.OhMyConnectionRequestAccepted(frame.payload).deserialize();
174
+ let packet = new _OhMyNewIncommingConnection.OhMyNewIncommingConnection();
179
175
  packet.internalAddress = new Array();
180
176
  for(let i = 0; i < 10; i++){
181
177
  packet.internalAddress[i] = new _raknet.Address('0.0.0.0', 0, 4);
182
178
  }
183
- packet.serverAddress = new _raknet.Address(des.address.address, des.address.port, 4);
179
+ packet.serverAddress = des.serverAddress;
184
180
  packet.incomingTimestamp = BigInt(Date.now());
185
- packet.serverTimestamp = des.timestamp;
181
+ packet.serverTimestamp = des.serverTimestamp;
182
+ return packet;
183
+ }
184
+ handleConnectionRequestAccepted(frame) {
185
+ let des;
186
+ let packet;
187
+ try {
188
+ const IncomingPacket = new _raknet.ConnectionRequestAccepted(frame.payload);
189
+ des = IncomingPacket.deserialize();
190
+ packet = new _OhMyNewIncommingConnection.OhMyNewIncommingConnection();
191
+ packet.internalAddress = new Array();
192
+ for(let i = 0; i < 10; i++){
193
+ packet.internalAddress[i] = new _raknet.Address('0.0.0.0', 0, 4);
194
+ }
195
+ packet.serverAddress = new _raknet.Address(des.address.address, des.address.port, 4);
196
+ packet.incomingTimestamp = BigInt(Date.now());
197
+ packet.serverTimestamp = des.timestamp;
198
+ } catch (error) {
199
+ packet = this.handleConnectionRequestAcceptedTwo(frame);
200
+ }
201
+ if (!packet) {
202
+ console.error('Failed to deserialize IncomingPacket!');
203
+ return;
204
+ }
186
205
  const sendFrame = new _raknet.Frame();
187
206
  sendFrame.reliability = _raknet.Reliability.ReliableOrdered;
188
207
  sendFrame.orderChannel = 0;
@@ -0,0 +1,20 @@
1
+ import { Address, BasePacket } from "@serenityjs/raknet";
2
+ declare class OhMyConnectionRequestAccepted extends BasePacket {
3
+ /**
4
+ * the server adress of the reply.
5
+ */
6
+ serverAddress: Address;
7
+ /**
8
+ * unknown what this is used for.
9
+ */
10
+ internalAddress: Address;
11
+ /**
12
+ * The incoming timestamp of the reply.
13
+ */
14
+ incomingTimestamp: bigint;
15
+ /**
16
+ * The server timestamp of the reply.
17
+ */
18
+ serverTimestamp: bigint;
19
+ }
20
+ export { OhMyConnectionRequestAccepted };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "OhMyConnectionRequestAccepted", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return OhMyConnectionRequestAccepted;
9
+ }
10
+ });
11
+ const _ts_decorate = require("@swc/helpers/_/_ts_decorate");
12
+ const _proto = require("../proto");
13
+ const _serialize = require("../serialize");
14
+ const _raknet = require("@serenityjs/raknet");
15
+ const _binarystream = require("@serenityjs/binarystream");
16
+ class OhMyConnectionRequestAccepted extends _raknet.BasePacket {
17
+ }
18
+ _ts_decorate._([
19
+ (0, _serialize.Serialize)(_raknet.Address)
20
+ ], OhMyConnectionRequestAccepted.prototype, "serverAddress", void 0);
21
+ _ts_decorate._([
22
+ (0, _serialize.Serialize)(_raknet.Address)
23
+ ], OhMyConnectionRequestAccepted.prototype, "internalAddress", void 0);
24
+ _ts_decorate._([
25
+ (0, _serialize.Serialize)(_binarystream.Long)
26
+ ], OhMyConnectionRequestAccepted.prototype, "incomingTimestamp", void 0);
27
+ _ts_decorate._([
28
+ (0, _serialize.Serialize)(_binarystream.Long)
29
+ ], OhMyConnectionRequestAccepted.prototype, "serverTimestamp", void 0);
30
+ OhMyConnectionRequestAccepted = _ts_decorate._([
31
+ (0, _proto.Proto)(_raknet.Packet.ConnectionRequestAccepted)
32
+ ], OhMyConnectionRequestAccepted);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanctumterra/raknet",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "emitDeclarationOnly": true,