@sanctumterra/raknet 1.0.17 → 1.0.18
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/.github/workflows/publish.yml +24 -0
- package/README.md +15 -0
- package/dist/index.d.ts +158 -13
- package/dist/index.js +1929 -51
- package/package.json +14 -27
- package/src/client/index.ts +4 -0
- package/src/client/packets/connected-ping.ts +10 -0
- package/src/client/packets/connected-pong.ts +10 -0
- package/src/client/packets/connection-request-accepted.ts +13 -0
- package/src/client/packets/connection-request.ts +11 -0
- package/src/client/packets/index.ts +11 -0
- package/src/client/packets/new-incoming-connection.ts +12 -0
- package/src/client/packets/open-connection-first-reply.ts +12 -0
- package/src/client/packets/open-connection-second-reply.ts +13 -0
- package/src/client/packets/open-connection-second-request.ts +12 -0
- package/src/client/packets/open-first-connection-request.ts +11 -0
- package/src/client/packets/unconnected-ping.ts +11 -0
- package/src/client/raknet-client.ts +88 -0
- package/src/client/receiver.ts +351 -0
- package/src/client/sender.ts +102 -0
- package/src/index.ts +4 -0
- package/src/tools/test.ts +17 -0
- package/src/vendor/Advertisement.ts +15 -0
- package/src/vendor/Logger.ts +73 -0
- package/src/vendor/index.ts +1 -0
- package/test.js +7 -0
- package/tsconfig.json +29 -0
- package/tsup.config.ts +9 -0
- package/dist/Tests/Connect.d.ts +0 -1
- package/dist/Tests/Connect.js +0 -11
- package/dist/Tests/JSPing.js +0 -6
- package/dist/Tests/Ping.d.ts +0 -1
- package/dist/Tests/Ping.js +0 -9
- package/dist/src/client/FrameHandler.d.ts +0 -27
- package/dist/src/client/FrameHandler.js +0 -233
- package/dist/src/client/PacketHandler.d.ts +0 -13
- package/dist/src/client/PacketHandler.js +0 -93
- package/dist/src/client/Queue.d.ts +0 -25
- package/dist/src/client/Queue.js +0 -90
- package/dist/src/client/RaknetClient.d.ts +0 -37
- package/dist/src/client/RaknetClient.js +0 -98
- package/dist/src/packets/proto.d.ts +0 -9
- package/dist/src/packets/proto.js +0 -122
- package/dist/src/packets/raknet/NewConnectionRequest.d.ts +0 -8
- package/dist/src/packets/raknet/NewConnectionRequest.js +0 -21
- package/dist/src/packets/raknet/OhMyConnectionRequestAccepted.d.ts +0 -20
- package/dist/src/packets/raknet/OhMyConnectionRequestAccepted.js +0 -32
- package/dist/src/packets/raknet/OhMyNewIncommingConnection.d.ts +0 -21
- package/dist/src/packets/raknet/OhMyNewIncommingConnection.js +0 -33
- package/dist/src/packets/serialize.d.ts +0 -4
- package/dist/src/packets/serialize.js +0 -29
- package/dist/src/utils/Logger.d.ts +0 -13
- package/dist/src/utils/Logger.js +0 -84
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Publish to to npm
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: v2
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
permissions:
|
|
10
|
+
id-token: write
|
|
11
|
+
contents: read
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version: '20.x'
|
|
18
|
+
registry-url: 'https://registry.npmjs.org'
|
|
19
|
+
- run: npm install
|
|
20
|
+
- run: npm run build
|
|
21
|
+
- run: npm publish --access=public
|
|
22
|
+
env:
|
|
23
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
24
|
+
|
package/README.md
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,158 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { BasePacket, Magic, Address, Frame, FrameSet, Priority, Status } from '@serenityjs/raknet';
|
|
2
|
+
import EventEmitter from 'events';
|
|
3
|
+
import dgram from 'dgram';
|
|
4
|
+
|
|
5
|
+
declare class OpenFirstConnectionRequest extends BasePacket {
|
|
6
|
+
magic: Magic;
|
|
7
|
+
protocol: number;
|
|
8
|
+
mtu: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare class UnconnectedPing extends BasePacket {
|
|
12
|
+
timestamp: bigint;
|
|
13
|
+
magic: Buffer;
|
|
14
|
+
client: bigint;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare class OpenConnectionFirstReply extends BasePacket {
|
|
18
|
+
magic: Buffer;
|
|
19
|
+
guid: bigint;
|
|
20
|
+
security: boolean;
|
|
21
|
+
mtu: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare class OpenConnectionSecondRequest extends BasePacket {
|
|
25
|
+
magic: Buffer;
|
|
26
|
+
address: Address;
|
|
27
|
+
mtu: number;
|
|
28
|
+
client: bigint;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare class OpenConnectionSecondReply extends BasePacket {
|
|
32
|
+
magic: Buffer;
|
|
33
|
+
guid: bigint;
|
|
34
|
+
address: Address;
|
|
35
|
+
mtu: number;
|
|
36
|
+
encryption: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare class ConnectionRequest extends BasePacket {
|
|
40
|
+
client: bigint;
|
|
41
|
+
timestamp: bigint;
|
|
42
|
+
security: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare class ConnectionRequestAccepted extends BasePacket {
|
|
46
|
+
address: Address;
|
|
47
|
+
systemIndex: number;
|
|
48
|
+
systemAddresses: Address[];
|
|
49
|
+
requestTimestamp: bigint;
|
|
50
|
+
timestamp: bigint;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare class NewIncomingConnection extends BasePacket {
|
|
54
|
+
serverAddress: Address;
|
|
55
|
+
internalAddresses: Address[];
|
|
56
|
+
incomingTimestamp: bigint;
|
|
57
|
+
serverTimestamp: bigint;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare class ConnectedPing extends BasePacket {
|
|
61
|
+
timestamp: bigint;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
declare class ConnectedPong extends BasePacket {
|
|
65
|
+
pingTime: bigint;
|
|
66
|
+
pongTime: bigint;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare class Receiver {
|
|
70
|
+
private lastInputSequence;
|
|
71
|
+
private receivedFrameSequences;
|
|
72
|
+
private lostFrameSequences;
|
|
73
|
+
private inputHighestSequenceIndex;
|
|
74
|
+
private inputOrderIndex;
|
|
75
|
+
protected inputOrderingQueue: Map<number, Map<number, Frame>>;
|
|
76
|
+
protected readonly fragmentsQueue: Map<number, Map<number, Frame>>;
|
|
77
|
+
private raknet;
|
|
78
|
+
constructor(raknet: RakNetClient);
|
|
79
|
+
incomingMessage(buffer: Buffer): void;
|
|
80
|
+
otherPackets(buffer: Buffer): void;
|
|
81
|
+
handleOpenConnectionRequest2(buffer: Buffer): void;
|
|
82
|
+
handleOpenConnectionRequest(): void;
|
|
83
|
+
sendConnectionPacket(): void;
|
|
84
|
+
sendUnconnectedPing(): void;
|
|
85
|
+
private tick;
|
|
86
|
+
send(buffer: Buffer): void;
|
|
87
|
+
handleFrameSet(buffer: Buffer): void;
|
|
88
|
+
private handleFrame;
|
|
89
|
+
private processFrame;
|
|
90
|
+
private handleFragment;
|
|
91
|
+
private reassembleAndProcessFragment;
|
|
92
|
+
private handleSequenced;
|
|
93
|
+
private handleOrdered;
|
|
94
|
+
private processOrderedFrames;
|
|
95
|
+
private handleConnectedPing;
|
|
96
|
+
handleConnectionRequestAcceptedTwo(frame: Frame): NewIncomingConnection;
|
|
97
|
+
private handleConnectionRequestAccepted;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
declare class Sender {
|
|
101
|
+
outputOrderIndex: Array<number>;
|
|
102
|
+
outputSequenceIndex: Array<number>;
|
|
103
|
+
outputFrameQueue: FrameSet;
|
|
104
|
+
mtu: number;
|
|
105
|
+
protected outputSequence: number;
|
|
106
|
+
protected outputsplitIndex: number;
|
|
107
|
+
protected outputReliableIndex: number;
|
|
108
|
+
protected outputFrames: Set<Frame>;
|
|
109
|
+
outputBackup: Map<number, Frame[]>;
|
|
110
|
+
protected client: RakNetClient;
|
|
111
|
+
constructor(client: RakNetClient);
|
|
112
|
+
onTick(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Sends a frame to the connection.
|
|
115
|
+
*
|
|
116
|
+
* @param frame - The frame to send
|
|
117
|
+
* @param priority - The priority of the frame
|
|
118
|
+
*/
|
|
119
|
+
sendFrame(frame: Frame, priority: Priority): void;
|
|
120
|
+
private queueFrame;
|
|
121
|
+
sendQueue(amount: number): void;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare class RakNetClient extends EventEmitter {
|
|
125
|
+
socket: dgram.Socket;
|
|
126
|
+
private ticker;
|
|
127
|
+
receiver: Receiver;
|
|
128
|
+
sender: Sender;
|
|
129
|
+
private id;
|
|
130
|
+
private address;
|
|
131
|
+
private port;
|
|
132
|
+
status: Status;
|
|
133
|
+
protocol: number;
|
|
134
|
+
mtu: number;
|
|
135
|
+
debug: boolean;
|
|
136
|
+
constructor(protocol?: number, debug?: boolean);
|
|
137
|
+
connect(address: string, port: number): Promise<void>;
|
|
138
|
+
ping(): void;
|
|
139
|
+
close(): Promise<void>;
|
|
140
|
+
send(packet: Buffer): void;
|
|
141
|
+
getAddress(): Address;
|
|
142
|
+
getId(): bigint;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
type VersionType = 'MCPE' | 'MCEE';
|
|
146
|
+
interface Advertisement {
|
|
147
|
+
type: VersionType;
|
|
148
|
+
message: string;
|
|
149
|
+
protocol: number;
|
|
150
|
+
version: string;
|
|
151
|
+
playerCount: number;
|
|
152
|
+
maxPlayers: number;
|
|
153
|
+
serverGUID: number;
|
|
154
|
+
serverName: string;
|
|
155
|
+
gameMode: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export { type Advertisement, ConnectedPing, ConnectedPong, ConnectionRequest, ConnectionRequestAccepted, NewIncomingConnection, OpenConnectionFirstReply, OpenConnectionSecondReply, OpenConnectionSecondRequest, OpenFirstConnectionRequest, RakNetClient, Receiver, Sender, UnconnectedPing, type VersionType };
|