@sanctumterra/raknet 1.3.80 → 1.4.0
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/README.md +1 -1
- package/dist/client/client.d.ts +19 -20
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +139 -184
- package/dist/client/types/client-events.d.ts +5 -20
- package/dist/client/types/client-events.d.ts.map +1 -1
- package/dist/client/types/client-options.d.ts +7 -8
- package/dist/client/types/client-options.d.ts.map +1 -1
- package/dist/client/types/client-options.js +9 -9
- package/dist/client/types/index.d.ts +1 -1
- package/dist/client/types/index.d.ts.map +1 -1
- package/dist/client/types/index.js +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/server/connection.d.ts +20 -59
- package/dist/server/connection.d.ts.map +1 -1
- package/dist/server/connection.js +53 -365
- package/dist/server/index.d.ts +2 -3
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -3
- package/dist/server/server.d.ts +11 -18
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +98 -137
- package/dist/{proto → server}/types/advertisement.d.ts +1 -1
- package/dist/server/types/advertisement.d.ts.map +1 -0
- package/dist/{proto → server}/types/advertisement.js +14 -10
- package/dist/server/types/connection-events.d.ts +4 -0
- package/dist/server/types/connection-events.d.ts.map +1 -0
- package/dist/server/types/index.d.ts +5 -0
- package/dist/server/types/index.d.ts.map +1 -0
- package/dist/{proto → server}/types/index.js +3 -1
- package/dist/server/types/server-events.d.ts +7 -0
- package/dist/server/types/server-events.d.ts.map +1 -0
- package/dist/server/types/server-options.d.ts +12 -0
- package/dist/server/types/server-options.d.ts.map +1 -0
- package/dist/server/types/server-options.js +14 -0
- package/dist/shared/emitter.d.ts +28 -0
- package/dist/shared/emitter.d.ts.map +1 -0
- package/dist/shared/emitter.js +71 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/{proto/decorators → shared}/index.js +4 -2
- package/dist/{utils/Logger.d.ts → shared/logger.d.ts} +1 -1
- package/dist/shared/logger.d.ts.map +1 -0
- package/dist/shared/network_session.d.ts +34 -0
- package/dist/shared/network_session.d.ts.map +1 -0
- package/dist/shared/network_session.js +247 -0
- package/dist/shared/proto/enums/connectionStatus.d.ts +8 -0
- package/dist/shared/proto/enums/connectionStatus.d.ts.map +1 -0
- package/dist/shared/proto/enums/connectionStatus.js +11 -0
- package/dist/shared/proto/enums/index.d.ts +5 -0
- package/dist/shared/proto/enums/index.d.ts.map +1 -0
- package/dist/{proto → shared/proto}/enums/index.js +2 -3
- package/dist/shared/proto/enums/packets.d.ts +19 -0
- package/dist/shared/proto/enums/packets.d.ts.map +1 -0
- package/dist/shared/proto/enums/packets.js +23 -0
- package/dist/shared/proto/enums/priority.d.ts +6 -0
- package/dist/shared/proto/enums/priority.d.ts.map +1 -0
- package/dist/shared/proto/enums/priority.js +4 -0
- package/dist/shared/proto/enums/reliability.d.ts.map +1 -0
- package/dist/shared/proto/index.d.ts +5 -0
- package/dist/shared/proto/index.d.ts.map +1 -0
- package/dist/{proto → shared/proto}/index.js +3 -3
- package/dist/shared/proto/offline/index.d.ts +7 -0
- package/dist/shared/proto/offline/index.d.ts.map +1 -0
- package/dist/shared/proto/offline/index.js +22 -0
- package/dist/shared/proto/offline/open-connection-reply-one.d.ts +9 -0
- package/dist/shared/proto/offline/open-connection-reply-one.d.ts.map +1 -0
- package/dist/shared/proto/offline/open-connection-reply-one.js +28 -0
- package/dist/shared/proto/offline/open-connection-reply-two.d.ts +11 -0
- package/dist/shared/proto/offline/open-connection-reply-two.d.ts.map +1 -0
- package/dist/shared/proto/offline/open-connection-reply-two.js +31 -0
- package/dist/shared/proto/offline/open-connection-request-one.d.ts +8 -0
- package/dist/shared/proto/offline/open-connection-request-one.d.ts.map +1 -0
- package/dist/shared/proto/offline/open-connection-request-one.js +25 -0
- package/dist/shared/proto/offline/open-connection-request-two.d.ts +10 -0
- package/dist/shared/proto/offline/open-connection-request-two.d.ts.map +1 -0
- package/dist/shared/proto/offline/open-connection-request-two.js +28 -0
- package/dist/shared/proto/offline/unconnected-ping.d.ts +8 -0
- package/dist/shared/proto/offline/unconnected-ping.d.ts.map +1 -0
- package/dist/shared/proto/offline/unconnected-ping.js +25 -0
- package/dist/shared/proto/offline/unconnected-pong.d.ts +9 -0
- package/dist/shared/proto/offline/unconnected-pong.d.ts.map +1 -0
- package/dist/shared/proto/offline/unconnected-pong.js +28 -0
- package/dist/shared/proto/online/ack.d.ts +7 -0
- package/dist/shared/proto/online/ack.d.ts.map +1 -0
- package/dist/{proto/packets → shared/proto/online}/ack.js +16 -31
- package/dist/shared/proto/online/connected-ping.d.ts +7 -0
- package/dist/shared/proto/online/connected-ping.d.ts.map +1 -0
- package/dist/shared/proto/online/connected-ping.js +19 -0
- package/dist/shared/proto/online/connected-pong.d.ts +8 -0
- package/dist/shared/proto/online/connected-pong.d.ts.map +1 -0
- package/dist/shared/proto/online/connected-pong.js +22 -0
- package/dist/shared/proto/online/connection-request-accepted.d.ts +12 -0
- package/dist/shared/proto/online/connection-request-accepted.d.ts.map +1 -0
- package/dist/shared/proto/online/connection-request-accepted.js +37 -0
- package/dist/shared/proto/online/connection-request.d.ts +9 -0
- package/dist/shared/proto/online/connection-request.d.ts.map +1 -0
- package/dist/shared/proto/online/connection-request.js +25 -0
- package/dist/shared/proto/online/disconnect-message.d.ts +6 -0
- package/dist/shared/proto/online/disconnect-message.d.ts.map +1 -0
- package/dist/shared/proto/online/disconnect-message.js +15 -0
- package/dist/shared/proto/online/frame-set.d.ts +9 -0
- package/dist/shared/proto/online/frame-set.d.ts.map +1 -0
- package/dist/shared/proto/online/frame-set.js +23 -0
- package/dist/shared/proto/online/index.d.ts +9 -0
- package/dist/shared/proto/online/index.d.ts.map +1 -0
- package/dist/shared/proto/online/index.js +24 -0
- package/dist/shared/proto/online/new-incomming-connection.d.ts +11 -0
- package/dist/shared/proto/online/new-incomming-connection.d.ts.map +1 -0
- package/dist/shared/proto/online/new-incomming-connection.js +33 -0
- package/dist/shared/proto/types/address.d.ts +12 -0
- package/dist/shared/proto/types/address.d.ts.map +1 -0
- package/dist/shared/proto/types/address.js +61 -0
- package/dist/shared/proto/types/frame.d.ts +23 -0
- package/dist/shared/proto/types/frame.d.ts.map +1 -0
- package/dist/shared/proto/types/frame.js +119 -0
- package/dist/{proto/packets → shared/proto}/types/index.d.ts +0 -2
- package/dist/shared/proto/types/index.d.ts.map +1 -0
- package/dist/{proto/packets → shared/proto}/types/index.js +0 -2
- package/dist/shared/proto/types/magic.d.ts +7 -0
- package/dist/shared/proto/types/magic.d.ts.map +1 -0
- package/dist/shared/proto/types/magic.js +15 -0
- package/dist/shared/proto/types/mtu.d.ts +7 -0
- package/dist/shared/proto/types/mtu.d.ts.map +1 -0
- package/dist/shared/proto/types/mtu.js +13 -0
- package/dist/tests/client-connect.d.ts +2 -0
- package/dist/tests/client-connect.d.ts.map +1 -0
- package/dist/tests/client-connect.js +32 -0
- package/dist/tests/client-once.d.ts +2 -0
- package/dist/tests/client-once.d.ts.map +1 -0
- package/dist/tests/client-once.js +11 -0
- package/dist/tests/server-listen.d.ts +2 -0
- package/dist/tests/server-listen.d.ts.map +1 -0
- package/dist/tests/server-listen.js +5 -0
- package/package.json +6 -6
- package/bun.lock +0 -67
- package/dist/client/framer.d.ts +0 -55
- package/dist/client/framer.d.ts.map +0 -1
- package/dist/client/framer.js +0 -458
- package/dist/proto/decorators/create.d.ts +0 -8
- package/dist/proto/decorators/create.d.ts.map +0 -1
- package/dist/proto/decorators/create.js +0 -77
- package/dist/proto/decorators/index.d.ts +0 -3
- package/dist/proto/decorators/index.d.ts.map +0 -1
- package/dist/proto/decorators/serialize.d.ts +0 -4
- package/dist/proto/decorators/serialize.d.ts.map +0 -1
- package/dist/proto/decorators/serialize.js +0 -12
- package/dist/proto/enums/flags.d.ts +0 -7
- package/dist/proto/enums/flags.d.ts.map +0 -1
- package/dist/proto/enums/flags.js +0 -10
- package/dist/proto/enums/index.d.ts +0 -6
- package/dist/proto/enums/index.d.ts.map +0 -1
- package/dist/proto/enums/packet.d.ts +0 -122
- package/dist/proto/enums/packet.d.ts.map +0 -1
- package/dist/proto/enums/packet.js +0 -125
- package/dist/proto/enums/priority.d.ts +0 -5
- package/dist/proto/enums/priority.d.ts.map +0 -1
- package/dist/proto/enums/priority.js +0 -8
- package/dist/proto/enums/reliability.d.ts.map +0 -1
- package/dist/proto/enums/status.d.ts +0 -7
- package/dist/proto/enums/status.d.ts.map +0 -1
- package/dist/proto/enums/status.js +0 -10
- package/dist/proto/index.d.ts +0 -5
- package/dist/proto/index.d.ts.map +0 -1
- package/dist/proto/packets/ack.d.ts +0 -10
- package/dist/proto/packets/ack.d.ts.map +0 -1
- package/dist/proto/packets/base-packet.d.ts +0 -26
- package/dist/proto/packets/base-packet.d.ts.map +0 -1
- package/dist/proto/packets/base-packet.js +0 -37
- package/dist/proto/packets/connected-ping.d.ts +0 -5
- package/dist/proto/packets/connected-ping.d.ts.map +0 -1
- package/dist/proto/packets/connected-ping.js +0 -27
- package/dist/proto/packets/connected-pong.d.ts +0 -6
- package/dist/proto/packets/connected-pong.d.ts.map +0 -1
- package/dist/proto/packets/connected-pong.js +0 -32
- package/dist/proto/packets/connection-request-accepted.d.ts +0 -10
- package/dist/proto/packets/connection-request-accepted.d.ts.map +0 -1
- package/dist/proto/packets/connection-request-accepted.js +0 -48
- package/dist/proto/packets/connection-request.d.ts +0 -7
- package/dist/proto/packets/connection-request.d.ts.map +0 -1
- package/dist/proto/packets/connection-request.js +0 -37
- package/dist/proto/packets/disconnect.d.ts +0 -5
- package/dist/proto/packets/disconnect.d.ts.map +0 -1
- package/dist/proto/packets/disconnect.js +0 -17
- package/dist/proto/packets/frame.d.ts +0 -1
- package/dist/proto/packets/frame.d.ts.map +0 -1
- package/dist/proto/packets/frame.js +0 -1
- package/dist/proto/packets/frameset.d.ts +0 -11
- package/dist/proto/packets/frameset.d.ts.map +0 -1
- package/dist/proto/packets/frameset.js +0 -37
- package/dist/proto/packets/incompatible-protocol-version.d.ts +0 -8
- package/dist/proto/packets/incompatible-protocol-version.d.ts.map +0 -1
- package/dist/proto/packets/incompatible-protocol-version.js +0 -38
- package/dist/proto/packets/index.d.ts +0 -19
- package/dist/proto/packets/index.d.ts.map +0 -1
- package/dist/proto/packets/index.js +0 -34
- package/dist/proto/packets/nack.d.ts +0 -8
- package/dist/proto/packets/nack.d.ts.map +0 -1
- package/dist/proto/packets/nack.js +0 -88
- package/dist/proto/packets/new-incoming-connection.d.ts +0 -9
- package/dist/proto/packets/new-incoming-connection.d.ts.map +0 -1
- package/dist/proto/packets/new-incoming-connection.js +0 -43
- package/dist/proto/packets/open-connection-reply-one.d.ts +0 -8
- package/dist/proto/packets/open-connection-reply-one.d.ts.map +0 -1
- package/dist/proto/packets/open-connection-reply-one.js +0 -43
- package/dist/proto/packets/open-connection-reply-two.d.ts +0 -10
- package/dist/proto/packets/open-connection-reply-two.d.ts.map +0 -1
- package/dist/proto/packets/open-connection-reply-two.js +0 -48
- package/dist/proto/packets/open-connection-request-one.d.ts +0 -7
- package/dist/proto/packets/open-connection-request-one.d.ts.map +0 -1
- package/dist/proto/packets/open-connection-request-one.js +0 -38
- package/dist/proto/packets/open-connection-request-two.d.ts +0 -9
- package/dist/proto/packets/open-connection-request-two.d.ts.map +0 -1
- package/dist/proto/packets/open-connection-request-two.js +0 -43
- package/dist/proto/packets/types/address.d.ts +0 -48
- package/dist/proto/packets/types/address.d.ts.map +0 -1
- package/dist/proto/packets/types/address.js +0 -99
- package/dist/proto/packets/types/data-type.d.ts +0 -21
- package/dist/proto/packets/types/data-type.d.ts.map +0 -1
- package/dist/proto/packets/types/data-type.js +0 -29
- package/dist/proto/packets/types/frame.d.ts +0 -23
- package/dist/proto/packets/types/frame.d.ts.map +0 -1
- package/dist/proto/packets/types/frame.js +0 -94
- package/dist/proto/packets/types/index.d.ts.map +0 -1
- package/dist/proto/packets/types/magic.d.ts +0 -7
- package/dist/proto/packets/types/magic.d.ts.map +0 -1
- package/dist/proto/packets/types/magic.js +0 -14
- package/dist/proto/packets/types/mtu.d.ts +0 -9
- package/dist/proto/packets/types/mtu.d.ts.map +0 -1
- package/dist/proto/packets/types/mtu.js +0 -18
- package/dist/proto/packets/types/sys-address.d.ts +0 -11
- package/dist/proto/packets/types/sys-address.d.ts.map +0 -1
- package/dist/proto/packets/types/sys-address.js +0 -32
- package/dist/proto/packets/unconnected-ping.d.ts +0 -7
- package/dist/proto/packets/unconnected-ping.d.ts.map +0 -1
- package/dist/proto/packets/unconnected-ping.js +0 -38
- package/dist/proto/packets/unconnected-pong.d.ts +0 -8
- package/dist/proto/packets/unconnected-pong.d.ts.map +0 -1
- package/dist/proto/packets/unconnected-pong.js +0 -43
- package/dist/proto/types/advertisement.d.ts.map +0 -1
- package/dist/proto/types/index.d.ts +0 -3
- package/dist/proto/types/index.d.ts.map +0 -1
- package/dist/proto/types/valid.d.ts +0 -4
- package/dist/proto/types/valid.d.ts.map +0 -1
- package/dist/server/server-events.d.ts +0 -9
- package/dist/server/server-events.d.ts.map +0 -1
- package/dist/server/server-options.d.ts +0 -26
- package/dist/server/server-options.d.ts.map +0 -1
- package/dist/server/server-options.js +0 -20
- package/dist/tests/client.d.ts +0 -2
- package/dist/tests/client.d.ts.map +0 -1
- package/dist/tests/client.js +0 -15
- package/dist/tests/localhost.d.ts +0 -2
- package/dist/tests/localhost.d.ts.map +0 -1
- package/dist/tests/localhost.js +0 -34
- package/dist/tests/server.d.ts +0 -2
- package/dist/tests/server.d.ts.map +0 -1
- package/dist/tests/server.js +0 -32
- package/dist/tests/test.d.ts +0 -2
- package/dist/tests/test.d.ts.map +0 -1
- package/dist/tests/test.js +0 -49
- package/dist/utils/Logger.d.ts.map +0 -1
- package/dist/utils/decorators.d.ts +0 -2
- package/dist/utils/decorators.d.ts.map +0 -1
- package/dist/utils/decorators.js +0 -17
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -18
- /package/dist/{proto/types/valid.js → server/types/connection-events.js} +0 -0
- /package/dist/server/{server-events.js → types/server-events.js} +0 -0
- /package/dist/{utils/Logger.js → shared/logger.js} +0 -0
- /package/dist/{proto → shared/proto}/enums/reliability.d.ts +0 -0
- /package/dist/{proto → shared/proto}/enums/reliability.js +0 -0
package/README.md
CHANGED
package/dist/client/client.d.ts
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { type
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export declare class Client extends Emitter<ClientEvents> {
|
|
7
|
-
socket: Socket | null;
|
|
8
|
-
framer: Framer | null;
|
|
1
|
+
import { EventEmitter, Priority, type Frame } from "../shared";
|
|
2
|
+
import type { ClientEvents } from "./types";
|
|
3
|
+
import { type ClientOptions } from "./types/client-options";
|
|
4
|
+
import { type RemoteInfo } from "node:dgram";
|
|
5
|
+
export declare class Client extends EventEmitter<ClientEvents> {
|
|
9
6
|
options: ClientOptions;
|
|
10
|
-
private
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
private socket;
|
|
8
|
+
private interval;
|
|
9
|
+
private status;
|
|
10
|
+
tick: number;
|
|
11
|
+
private session;
|
|
15
12
|
constructor(options?: Partial<ClientOptions>);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
connect(): Promise<void>;
|
|
14
|
+
onTick(): void;
|
|
15
|
+
onMessage(data: Buffer, rinfo: RemoteInfo): void;
|
|
16
|
+
handleOnline(data: Buffer): void;
|
|
17
|
+
sendFrame(frame: Frame, priority?: Priority): void;
|
|
18
|
+
frameAndSend(data: Buffer, priority?: Priority): void;
|
|
19
|
+
ping(): void;
|
|
20
|
+
send(data: Buffer): void;
|
|
21
|
+
disconnect(): void;
|
|
23
22
|
}
|
|
24
23
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,YAAY,EAWZ,QAAQ,EAIR,KAAK,KAAK,EAIV,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EACN,KAAK,aAAa,EAElB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAgB,KAAK,UAAU,EAAe,MAAM,YAAY,CAAC;AAGxE,qBAAa,MAAO,SAAQ,YAAY,CAAC,YAAY,CAAC;IAC9C,OAAO,EAAE,aAAa,CAAC;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,MAAM,CAAmB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,OAAO,CAAiB;gBAEpB,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM;IAmBzC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAkBxB,MAAM,IAAI,IAAI;IAYd,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IAqDhD,YAAY,CAAC,IAAI,EAAE,MAAM;IAwCzB,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,GAAE,QAA0B;IAI5D,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,QAA0B;IAI/D,IAAI,IAAI,IAAI;IAQZ,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIxB,UAAU,IAAI,IAAI;CAIzB"}
|
package/dist/client/client.js
CHANGED
|
@@ -1,210 +1,165 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.Client = void 0;
|
|
7
|
-
const
|
|
4
|
+
const shared_1 = require("../shared");
|
|
5
|
+
const client_options_1 = require("./types/client-options");
|
|
8
6
|
const node_dgram_1 = require("node:dgram");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
|
-
const framer_1 = require("./framer");
|
|
13
|
-
const types_1 = require("./types");
|
|
14
|
-
const TICK_INTERVAL = 50;
|
|
15
|
-
const REQUEST_INTERVAL = 500;
|
|
16
|
-
class Client extends emitter_1.Emitter {
|
|
17
|
-
socket;
|
|
18
|
-
framer;
|
|
7
|
+
const shared_2 = require("../shared");
|
|
8
|
+
class Client extends shared_1.EventEmitter {
|
|
19
9
|
options;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
constructor(options =
|
|
10
|
+
socket;
|
|
11
|
+
interval;
|
|
12
|
+
status;
|
|
13
|
+
tick;
|
|
14
|
+
session;
|
|
15
|
+
constructor(options = {}) {
|
|
26
16
|
super();
|
|
27
|
-
this.options = { ...
|
|
28
|
-
this.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
this.socket.on("error", (err) => {
|
|
41
|
-
utils_1.Logger.error(`[Client] Socket error: ${err}`);
|
|
42
|
-
});
|
|
43
|
-
utils_1.Logger.disabled = this.options.loggerDisabled;
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
utils_1.Logger.error(`Failed to create socket: ${error}`);
|
|
47
|
-
}
|
|
17
|
+
this.options = { ...client_options_1.defaultClientOptions, ...options };
|
|
18
|
+
this.status = shared_1.ConnectionStatus.Disconnected;
|
|
19
|
+
this.tick = 0;
|
|
20
|
+
this.socket = (0, node_dgram_1.createSocket)("udp4");
|
|
21
|
+
this.socket.bind();
|
|
22
|
+
this.interval = setInterval(this.onTick.bind(this), 1000 / this.options.tickRate);
|
|
23
|
+
this.socket.on("message", this.onMessage.bind(this));
|
|
24
|
+
this.session = new shared_1.NetworkSession(this.options.mtu);
|
|
25
|
+
this.session.send = this.send.bind(this);
|
|
26
|
+
this.session.handle = (data) => {
|
|
27
|
+
this.handleOnline(data);
|
|
28
|
+
};
|
|
48
29
|
}
|
|
49
|
-
|
|
30
|
+
connect() {
|
|
50
31
|
return new Promise((resolve, reject) => {
|
|
32
|
+
this.status = shared_1.ConnectionStatus.Connecting;
|
|
33
|
+
const request = new shared_1.OpenConnectionRequestOne();
|
|
34
|
+
request.mtu = this.options.mtu;
|
|
35
|
+
request.protocol = 11; // Only 11 is supported
|
|
36
|
+
const serialized = request.serialize();
|
|
37
|
+
this.send(serialized);
|
|
51
38
|
const timeout = setTimeout(() => {
|
|
52
|
-
reject(new Error("
|
|
39
|
+
reject(new Error("Connection timed out"));
|
|
53
40
|
}, this.options.timeout);
|
|
54
|
-
this.once("
|
|
41
|
+
this.once("connect", () => {
|
|
55
42
|
clearTimeout(timeout);
|
|
56
|
-
resolve(
|
|
43
|
+
resolve();
|
|
57
44
|
});
|
|
58
|
-
const unconnectedPing = new proto_1.UnconnectedPing();
|
|
59
|
-
unconnectedPing.guid = this.options.clientId;
|
|
60
|
-
unconnectedPing.clientTimestamp = BigInt(Date.now());
|
|
61
|
-
this.send(unconnectedPing.serialize());
|
|
62
45
|
});
|
|
63
46
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
onTick() {
|
|
48
|
+
const isDisconnected = this.status === shared_1.ConnectionStatus.Disconnected;
|
|
49
|
+
const isDisconnecting = this.status === shared_1.ConnectionStatus.Disconnecting;
|
|
50
|
+
const canPing = isDisconnected && this.tick % this.options.pingRate === 0;
|
|
51
|
+
if (canPing)
|
|
52
|
+
this.ping();
|
|
53
|
+
if (!isDisconnecting || !isDisconnected) {
|
|
54
|
+
this.session.onTick(this.tick);
|
|
67
55
|
}
|
|
68
|
-
|
|
69
|
-
throw new Error("Already connected");
|
|
70
|
-
}
|
|
71
|
-
this.status = proto_1.Status.Connecting;
|
|
72
|
-
this.initSocket();
|
|
73
|
-
this.tickTimer = setInterval(() => this.emit("tick"), TICK_INTERVAL);
|
|
74
|
-
let advertisement = null;
|
|
75
|
-
const pongHandler = (packet) => {
|
|
76
|
-
advertisement = (0, proto_1.fromString)(packet.message);
|
|
77
|
-
};
|
|
78
|
-
this.once("unconnected-pong", pongHandler);
|
|
79
|
-
const ping = new proto_1.UnconnectedPing();
|
|
80
|
-
ping.guid = this.options.clientId;
|
|
81
|
-
ping.clientTimestamp = BigInt(Date.now());
|
|
82
|
-
this.send(ping.serialize());
|
|
83
|
-
return new Promise((resolve, reject) => {
|
|
84
|
-
let isResolved = false;
|
|
85
|
-
let currentStage = 0; // 0: request-one, 1: request-two, 2: completed
|
|
86
|
-
this.connectionTimeout = setTimeout(() => {
|
|
87
|
-
if (!isResolved) {
|
|
88
|
-
isResolved = true;
|
|
89
|
-
this.disconnect();
|
|
90
|
-
reject(new Error("Connection timed out"));
|
|
91
|
-
}
|
|
92
|
-
}, this.options.timeout);
|
|
93
|
-
const requestOne = new proto_1.OpenConnectionRequestOne();
|
|
94
|
-
requestOne.mtu = this.options.mtuSize;
|
|
95
|
-
requestOne.protocol = this.options.protocolVersion;
|
|
96
|
-
this.once("open-connection-reply-one", () => {
|
|
97
|
-
currentStage = 1;
|
|
98
|
-
utils_1.Logger.debug("[Client] Received OpenConnectionReplyOne, sending OpenConnectionRequestTwo");
|
|
99
|
-
if (this.requestInterval)
|
|
100
|
-
clearInterval(this.requestInterval);
|
|
101
|
-
});
|
|
102
|
-
this.once("open-connection-reply-two", (packet) => {
|
|
103
|
-
const mtu = packet.mtu;
|
|
104
|
-
if (mtu < 400 || mtu > 1500) {
|
|
105
|
-
if (!isResolved) {
|
|
106
|
-
isResolved = true;
|
|
107
|
-
this.disconnect();
|
|
108
|
-
reject(new Error(`Invalid MTU size: ${mtu}`));
|
|
109
|
-
}
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
currentStage = 2;
|
|
113
|
-
utils_1.Logger.debug(`[Client] Received OpenConnectionReplyTwo with MTU: ${mtu}`);
|
|
114
|
-
});
|
|
115
|
-
this.once("new-incoming-connection", () => {
|
|
116
|
-
if (!isResolved) {
|
|
117
|
-
isResolved = true;
|
|
118
|
-
this.status = proto_1.Status.Connected;
|
|
119
|
-
this.emit("connect");
|
|
120
|
-
if (this.connectionTimeout)
|
|
121
|
-
clearTimeout(this.connectionTimeout);
|
|
122
|
-
if (this.requestInterval)
|
|
123
|
-
clearInterval(this.requestInterval);
|
|
124
|
-
resolve(advertisement);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
this.once("error", (error) => {
|
|
128
|
-
if (!isResolved) {
|
|
129
|
-
isResolved = true;
|
|
130
|
-
this.disconnect();
|
|
131
|
-
reject(error);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
this.emit("open-connection-request-one", requestOne);
|
|
135
|
-
this.send(requestOne.serialize());
|
|
136
|
-
this.requestInterval = setInterval(() => {
|
|
137
|
-
if (!isResolved && currentStage === 0) {
|
|
138
|
-
utils_1.Logger.debug("[Client] Resending OpenConnectionRequestOne");
|
|
139
|
-
this.send(requestOne.serialize());
|
|
140
|
-
}
|
|
141
|
-
}, REQUEST_INTERVAL);
|
|
142
|
-
});
|
|
56
|
+
this.tick++;
|
|
143
57
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
58
|
+
onMessage(data, rinfo) {
|
|
59
|
+
let id = data[0];
|
|
60
|
+
const isOnline = (id & 0xf0) === 0x80;
|
|
61
|
+
if (isOnline)
|
|
62
|
+
id = 0x80;
|
|
63
|
+
switch (id) {
|
|
64
|
+
case shared_1.Packets.UnconnectedPong: {
|
|
65
|
+
const pong = new shared_1.UnconnectedPong(data).deserialize();
|
|
66
|
+
this.emit("unconnectedPong", pong);
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
case shared_1.Packets.OpenConnectionReply1: {
|
|
70
|
+
const reply = new shared_1.OpenConnectionReplyOne(data).deserialize();
|
|
71
|
+
const request = new shared_1.OpenConnectionRequestTwo();
|
|
72
|
+
request.address = shared_1.Address.fromIdentifier(rinfo);
|
|
73
|
+
request.mtu = reply.mtu;
|
|
74
|
+
request.guid = this.options.guid;
|
|
75
|
+
this.send(request.serialize());
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case shared_1.Packets.OpenConnectionReply2: {
|
|
79
|
+
const reply = new shared_1.OpenConnectionReplyTwo(data).deserialize();
|
|
80
|
+
const request = new shared_1.ConnectionRequest();
|
|
81
|
+
request.guid = this.options.guid;
|
|
82
|
+
request.timestamp = BigInt(Date.now());
|
|
83
|
+
const serialized = request.serialize();
|
|
84
|
+
this.frameAndSend(serialized, shared_1.Priority.High);
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case shared_1.Packets.FrameSet: {
|
|
88
|
+
const frameSet = new shared_1.FrameSet(data).deserialize();
|
|
89
|
+
this.session.onFrameSet(frameSet);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case shared_1.Packets.Ack: {
|
|
93
|
+
const ack = new shared_1.Ack(data).deserialize();
|
|
94
|
+
this.session.onAck(ack);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case shared_1.Packets.Nack: {
|
|
98
|
+
const nack = new shared_1.Ack(data).deserialize();
|
|
99
|
+
this.session.onNack(nack);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
default: {
|
|
103
|
+
shared_2.Logger.warn(`Unknown packet type: ${id}`);
|
|
104
|
+
break;
|
|
149
105
|
}
|
|
150
|
-
this.framer.sendFrame(frame, priority);
|
|
151
106
|
}
|
|
152
|
-
|
|
153
|
-
|
|
107
|
+
}
|
|
108
|
+
handleOnline(data) {
|
|
109
|
+
const id = data[0];
|
|
110
|
+
switch (id) {
|
|
111
|
+
case 254: {
|
|
112
|
+
this.emit("encapsulated", data);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case shared_1.Packets.ConnectedPong: {
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case shared_1.Packets.ConnectedPing: {
|
|
119
|
+
const ping = new shared_1.ConnectedPing(data).deserialize();
|
|
120
|
+
const pong = new shared_1.ConnectedPong();
|
|
121
|
+
pong.pingTimestamp = ping.timestamp;
|
|
122
|
+
pong.pongTimestamp = BigInt(Date.now());
|
|
123
|
+
this.frameAndSend(ping.serialize(), shared_1.Priority.High);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case shared_1.Packets.ConnectionRequestAccepted: {
|
|
127
|
+
const accepted = new shared_1.ConnectionRequestAccepted(data).deserialize();
|
|
128
|
+
const nic = new shared_1.NewIncomingConnection();
|
|
129
|
+
nic.address = new shared_1.Address(this.socket.address().address, this.socket.address().port, this.socket.address().family === "IPv4" ? 4 : 6);
|
|
130
|
+
nic.internalAddress = new shared_1.Address("127.0.0.1", 0, 4);
|
|
131
|
+
nic.incomingTimestamp = BigInt(Date.now());
|
|
132
|
+
nic.serverTimestamp = accepted.timestamp;
|
|
133
|
+
this.frameAndSend(nic.serialize(), shared_1.Priority.High);
|
|
134
|
+
this.emit("connect");
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
default: {
|
|
138
|
+
shared_2.Logger.warn(`Unknown packet type: ${id}`);
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
154
141
|
}
|
|
155
142
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
frame.payload = payload;
|
|
159
|
-
frame.orderChannel = 0;
|
|
160
|
-
this.sendFrame(frame, priority);
|
|
143
|
+
sendFrame(frame, priority = shared_1.Priority.Medium) {
|
|
144
|
+
this.session.sendFrame(frame, priority);
|
|
161
145
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (err) {
|
|
175
|
-
utils_1.Logger.error("[Client] Failed to send packet", err);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
utils_1.Logger.error("[Client] Failed to send packet", error);
|
|
181
|
-
}
|
|
146
|
+
frameAndSend(data, priority = shared_1.Priority.Medium) {
|
|
147
|
+
this.session.frameAndSend(data, priority);
|
|
148
|
+
}
|
|
149
|
+
ping() {
|
|
150
|
+
const ping = new shared_1.UnconnectedPing();
|
|
151
|
+
ping.guid = this.options.guid;
|
|
152
|
+
ping.timestamp = BigInt(Date.now());
|
|
153
|
+
const serialized = ping.serialize();
|
|
154
|
+
this.send(serialized);
|
|
155
|
+
}
|
|
156
|
+
send(data) {
|
|
157
|
+
this.socket.send(data, this.options.port, this.options.address);
|
|
182
158
|
}
|
|
183
159
|
disconnect() {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
const wasConnected = this.status === proto_1.Status.Connected;
|
|
190
|
-
this.status = proto_1.Status.Disconnected;
|
|
191
|
-
if (this.tickTimer)
|
|
192
|
-
clearInterval(this.tickTimer);
|
|
193
|
-
if (this.connectionTimeout)
|
|
194
|
-
clearTimeout(this.connectionTimeout);
|
|
195
|
-
if (this.requestInterval)
|
|
196
|
-
clearInterval(this.requestInterval);
|
|
197
|
-
if (this.socket) {
|
|
198
|
-
if (wasConnected) {
|
|
199
|
-
const disconnect = new disconnect_1.default();
|
|
200
|
-
this.socket.send(disconnect.serialize(), 0, disconnect.serialize().length, this.options.port, this.options.address);
|
|
201
|
-
}
|
|
202
|
-
this.socket.close();
|
|
203
|
-
this.socket = null;
|
|
204
|
-
}
|
|
205
|
-
this.framer = null;
|
|
206
|
-
resolve();
|
|
207
|
-
});
|
|
160
|
+
this.socket.close();
|
|
161
|
+
if (this.interval)
|
|
162
|
+
clearInterval(this.interval);
|
|
208
163
|
}
|
|
209
164
|
}
|
|
210
165
|
exports.Client = Client;
|
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Frameset } from "../../proto/packets/frameset";
|
|
1
|
+
import type { UnconnectedPong } from "../../shared";
|
|
3
2
|
export interface ClientEvents {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"unconnected-ping": [UnconnectedPing];
|
|
9
|
-
"unconnected-pong": [UnconnectedPong];
|
|
10
|
-
frameset: [Frameset];
|
|
11
|
-
"connected-ping": [ConnectedPing];
|
|
12
|
-
"connected-pong": [ConnectedPong];
|
|
13
|
-
"connection-request": [ConnectionRequest];
|
|
14
|
-
"connection-request-accepted": [ConnectionRequestAccepted];
|
|
15
|
-
"new-incoming-connection": [NewIncomingConnection];
|
|
16
|
-
encapsulated: [Buffer];
|
|
17
|
-
ack: [Ack];
|
|
18
|
-
error: [Error];
|
|
19
|
-
close: [];
|
|
20
|
-
connect: [];
|
|
21
|
-
tick: [];
|
|
3
|
+
unconnectedPong: UnconnectedPong;
|
|
4
|
+
error: Error;
|
|
5
|
+
connect: undefined;
|
|
6
|
+
encapsulated: Buffer;
|
|
22
7
|
}
|
|
23
8
|
//# sourceMappingURL=client-events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-events.d.ts","sourceRoot":"","sources":["../../../src/client/types/client-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"client-events.d.ts","sourceRoot":"","sources":["../../../src/client/types/client-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,WAAW,YAAY;IAC5B,eAAe,EAAE,eAAe,CAAC;IACjC,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,SAAS,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
type ClientOptions = {
|
|
1
|
+
export type ClientOptions = {
|
|
2
|
+
mtu: number;
|
|
2
3
|
address: string;
|
|
3
4
|
port: number;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
debug: boolean;
|
|
5
|
+
guid: bigint;
|
|
6
|
+
tickRate: number;
|
|
7
|
+
pingRate: number;
|
|
8
8
|
timeout: number;
|
|
9
|
-
loggerDisabled: boolean;
|
|
10
9
|
};
|
|
11
|
-
declare const
|
|
12
|
-
export
|
|
10
|
+
export declare const getRandomGuid: () => bigint;
|
|
11
|
+
export declare const defaultClientOptions: ClientOptions;
|
|
13
12
|
//# sourceMappingURL=client-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-options.d.ts","sourceRoot":"","sources":["../../../src/client/types/client-options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client-options.d.ts","sourceRoot":"","sources":["../../../src/client/types/client-options.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,eAAO,MAAM,aAAa,cACgC,CAAC;AAE3D,eAAO,MAAM,oBAAoB,EAAE,aAQlC,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultClientOptions = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.defaultClientOptions = exports.getRandomGuid = void 0;
|
|
4
|
+
const getRandomGuid = () => BigInt(Math.floor(Date.now() + Math.random() * 10000000));
|
|
5
|
+
exports.getRandomGuid = getRandomGuid;
|
|
6
|
+
exports.defaultClientOptions = {
|
|
7
|
+
mtu: 1492,
|
|
5
8
|
address: "127.0.0.1",
|
|
6
9
|
port: 19132,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
timeout: 10000,
|
|
12
|
-
loggerDisabled: false,
|
|
10
|
+
guid: (0, exports.getRandomGuid)(),
|
|
11
|
+
tickRate: 20,
|
|
12
|
+
pingRate: 40,
|
|
13
|
+
timeout: 30000,
|
|
13
14
|
};
|
|
14
|
-
exports.defaultClientOptions = defaultClientOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./client-events"), exports);
|
|
18
17
|
__exportStar(require("./client-options"), exports);
|
|
18
|
+
__exportStar(require("./client-events"), exports);
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,8 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
require("reflect-metadata");
|
|
18
|
-
__exportStar(require("./proto"), exports);
|
|
19
|
-
__exportStar(require("./utils"), exports);
|
|
20
17
|
__exportStar(require("./client"), exports);
|
|
18
|
+
__exportStar(require("./shared"), exports);
|
|
21
19
|
__exportStar(require("./server"), exports);
|
|
@@ -1,62 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { RemoteInfo } from "node:dgram";
|
|
1
|
+
import { type Ack, EventEmitter, type Frame, type FrameSet, Priority } from "../shared";
|
|
3
2
|
import type { Server } from "./server";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
status: Status;
|
|
24
|
-
private lastUpdate;
|
|
25
|
-
protected readonly receivedFrameSequences: Set<number>;
|
|
26
|
-
protected readonly lostFrameSequences: Set<number>;
|
|
27
|
-
protected lastInputSequence: number;
|
|
28
|
-
protected fragmentsQueue: Map<number, FragmentGroup>;
|
|
29
|
-
private inputOrderIndex;
|
|
30
|
-
protected inputOrderingQueue: Map<number, Map<number, QueuedFrame>>;
|
|
31
|
-
private inputHighestSequenceIndex;
|
|
32
|
-
outputOrderIndex: number[];
|
|
33
|
-
outputSequenceIndex: number[];
|
|
34
|
-
protected outputFrameQueue: Frame[];
|
|
35
|
-
protected outputFramesByteLength: number;
|
|
36
|
-
protected outputSequence: number;
|
|
37
|
-
protected outputSplitIndex: number;
|
|
38
|
-
protected outputReliableIndex: number;
|
|
39
|
-
outputBackup: Map<number, Frame[]>;
|
|
40
|
-
private readonly ORDERING_QUEUE_TIMEOUT;
|
|
41
|
-
constructor(server: Server, remoteInfo: RemoteInfo, guid: bigint, mtu: number);
|
|
42
|
-
tick(): void;
|
|
43
|
-
private handlePackets;
|
|
44
|
-
handle(message: Buffer): void;
|
|
45
|
-
private handleFrameSet;
|
|
46
|
-
private handleFrame;
|
|
47
|
-
private handleSplit;
|
|
48
|
-
private handleOrdered;
|
|
49
|
-
private handleSequenced;
|
|
50
|
-
sendFrame(frame: Frame, priority: Priority): void;
|
|
51
|
-
private handleLargePayload;
|
|
52
|
-
private createSplitFrame;
|
|
53
|
-
private queueFrame;
|
|
54
|
-
sendQueue(amount: number): void;
|
|
55
|
-
frameAndSend(payload: Buffer | BinaryStream, priority: Priority): void;
|
|
56
|
-
send(message: Buffer): void;
|
|
57
|
-
disconnect(timeout?: boolean): void;
|
|
58
|
-
getConnectionTime(type?: "ms" | "s" | "min"): number;
|
|
59
|
-
getAddress(): Address;
|
|
3
|
+
import type { RemoteInfo } from "node:dgram";
|
|
4
|
+
import type { ConnectionEvents } from "./types";
|
|
5
|
+
export declare class Connection extends EventEmitter<ConnectionEvents> {
|
|
6
|
+
private server;
|
|
7
|
+
private rinfo;
|
|
8
|
+
private mtu;
|
|
9
|
+
private guid;
|
|
10
|
+
private session;
|
|
11
|
+
constructor(server: Server, rinfo: RemoteInfo, mtu: number, guid: bigint);
|
|
12
|
+
onTick(tick: number): void;
|
|
13
|
+
onFrameSet(frameSet: FrameSet): void;
|
|
14
|
+
getAddress(): RemoteInfo;
|
|
15
|
+
onMessage(data: Buffer): void;
|
|
16
|
+
onAck(message: Ack): void;
|
|
17
|
+
/** Nack Packet is same as Ack just different id's and we do not care about the ids. */
|
|
18
|
+
onNack(message: Ack): void;
|
|
19
|
+
sendFrame(frame: Frame, priority?: Priority): void;
|
|
20
|
+
frameAndSend(payload: Buffer, priority?: Priority): void;
|
|
21
|
+
send(data: Buffer): void;
|
|
60
22
|
}
|
|
61
|
-
export { Connection };
|
|
62
23
|
//# sourceMappingURL=connection.d.ts.map
|