@sanctumterra/raknet 1.3.79 → 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.
Files changed (286) hide show
  1. package/README.md +1 -1
  2. package/dist/client/client.d.ts +19 -24
  3. package/dist/client/client.d.ts.map +1 -1
  4. package/dist/client/client.js +135 -278
  5. package/dist/client/index.d.ts +1 -2
  6. package/dist/client/index.d.ts.map +1 -1
  7. package/dist/client/index.js +1 -2
  8. package/dist/client/types/client-events.d.ts +8 -0
  9. package/dist/client/types/client-events.d.ts.map +1 -0
  10. package/dist/client/types/client-options.d.ts +12 -0
  11. package/dist/client/types/client-options.d.ts.map +1 -0
  12. package/dist/client/types/client-options.js +14 -0
  13. package/dist/client/types/index.d.ts +3 -0
  14. package/dist/client/types/index.d.ts.map +1 -0
  15. package/dist/{proto/decorators → client/types}/index.js +2 -2
  16. package/dist/index.d.ts +1 -3
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -3
  19. package/dist/server/connection.d.ts +20 -59
  20. package/dist/server/connection.d.ts.map +1 -1
  21. package/dist/server/connection.js +53 -365
  22. package/dist/server/index.d.ts +2 -3
  23. package/dist/server/index.d.ts.map +1 -1
  24. package/dist/server/index.js +2 -3
  25. package/dist/server/server.d.ts +11 -18
  26. package/dist/server/server.d.ts.map +1 -1
  27. package/dist/server/server.js +98 -137
  28. package/dist/{proto → server}/types/advertisement.d.ts +1 -1
  29. package/dist/server/types/advertisement.d.ts.map +1 -0
  30. package/dist/{proto → server}/types/advertisement.js +14 -10
  31. package/dist/server/types/connection-events.d.ts +4 -0
  32. package/dist/server/types/connection-events.d.ts.map +1 -0
  33. package/dist/server/types/index.d.ts +5 -0
  34. package/dist/server/types/index.d.ts.map +1 -0
  35. package/dist/{proto → server}/types/index.js +3 -1
  36. package/dist/server/types/server-events.d.ts +7 -0
  37. package/dist/server/types/server-events.d.ts.map +1 -0
  38. package/dist/server/types/server-options.d.ts +12 -0
  39. package/dist/server/types/server-options.d.ts.map +1 -0
  40. package/dist/server/types/server-options.js +14 -0
  41. package/dist/shared/emitter.d.ts +28 -0
  42. package/dist/shared/emitter.d.ts.map +1 -0
  43. package/dist/shared/emitter.js +71 -0
  44. package/dist/shared/index.d.ts +5 -0
  45. package/dist/shared/index.d.ts.map +1 -0
  46. package/dist/{utils → shared}/index.js +4 -1
  47. package/dist/{utils/Logger.d.ts → shared/logger.d.ts} +1 -1
  48. package/dist/shared/logger.d.ts.map +1 -0
  49. package/dist/shared/network_session.d.ts +34 -0
  50. package/dist/shared/network_session.d.ts.map +1 -0
  51. package/dist/shared/network_session.js +247 -0
  52. package/dist/shared/proto/enums/connectionStatus.d.ts +8 -0
  53. package/dist/shared/proto/enums/connectionStatus.d.ts.map +1 -0
  54. package/dist/shared/proto/enums/connectionStatus.js +11 -0
  55. package/dist/shared/proto/enums/index.d.ts +5 -0
  56. package/dist/shared/proto/enums/index.d.ts.map +1 -0
  57. package/dist/{proto → shared/proto}/enums/index.js +2 -3
  58. package/dist/shared/proto/enums/packets.d.ts +19 -0
  59. package/dist/shared/proto/enums/packets.d.ts.map +1 -0
  60. package/dist/shared/proto/enums/packets.js +23 -0
  61. package/dist/shared/proto/enums/priority.d.ts +6 -0
  62. package/dist/shared/proto/enums/priority.d.ts.map +1 -0
  63. package/dist/shared/proto/enums/priority.js +4 -0
  64. package/dist/shared/proto/enums/reliability.d.ts.map +1 -0
  65. package/dist/shared/proto/index.d.ts +5 -0
  66. package/dist/shared/proto/index.d.ts.map +1 -0
  67. package/dist/{proto → shared/proto}/index.js +3 -3
  68. package/dist/shared/proto/offline/index.d.ts +7 -0
  69. package/dist/shared/proto/offline/index.d.ts.map +1 -0
  70. package/dist/shared/proto/offline/index.js +22 -0
  71. package/dist/shared/proto/offline/open-connection-reply-one.d.ts +9 -0
  72. package/dist/shared/proto/offline/open-connection-reply-one.d.ts.map +1 -0
  73. package/dist/shared/proto/offline/open-connection-reply-one.js +28 -0
  74. package/dist/shared/proto/offline/open-connection-reply-two.d.ts +11 -0
  75. package/dist/shared/proto/offline/open-connection-reply-two.d.ts.map +1 -0
  76. package/dist/shared/proto/offline/open-connection-reply-two.js +31 -0
  77. package/dist/shared/proto/offline/open-connection-request-one.d.ts +8 -0
  78. package/dist/shared/proto/offline/open-connection-request-one.d.ts.map +1 -0
  79. package/dist/shared/proto/offline/open-connection-request-one.js +25 -0
  80. package/dist/shared/proto/offline/open-connection-request-two.d.ts +10 -0
  81. package/dist/shared/proto/offline/open-connection-request-two.d.ts.map +1 -0
  82. package/dist/shared/proto/offline/open-connection-request-two.js +28 -0
  83. package/dist/shared/proto/offline/unconnected-ping.d.ts +8 -0
  84. package/dist/shared/proto/offline/unconnected-ping.d.ts.map +1 -0
  85. package/dist/shared/proto/offline/unconnected-ping.js +25 -0
  86. package/dist/shared/proto/offline/unconnected-pong.d.ts +9 -0
  87. package/dist/shared/proto/offline/unconnected-pong.d.ts.map +1 -0
  88. package/dist/shared/proto/offline/unconnected-pong.js +28 -0
  89. package/dist/shared/proto/online/ack.d.ts +7 -0
  90. package/dist/shared/proto/online/ack.d.ts.map +1 -0
  91. package/dist/{proto/packets → shared/proto/online}/ack.js +16 -31
  92. package/dist/shared/proto/online/connected-ping.d.ts +7 -0
  93. package/dist/shared/proto/online/connected-ping.d.ts.map +1 -0
  94. package/dist/shared/proto/online/connected-ping.js +19 -0
  95. package/dist/shared/proto/online/connected-pong.d.ts +8 -0
  96. package/dist/shared/proto/online/connected-pong.d.ts.map +1 -0
  97. package/dist/shared/proto/online/connected-pong.js +22 -0
  98. package/dist/shared/proto/online/connection-request-accepted.d.ts +12 -0
  99. package/dist/shared/proto/online/connection-request-accepted.d.ts.map +1 -0
  100. package/dist/shared/proto/online/connection-request-accepted.js +37 -0
  101. package/dist/shared/proto/online/connection-request.d.ts +9 -0
  102. package/dist/shared/proto/online/connection-request.d.ts.map +1 -0
  103. package/dist/shared/proto/online/connection-request.js +25 -0
  104. package/dist/shared/proto/online/disconnect-message.d.ts +6 -0
  105. package/dist/shared/proto/online/disconnect-message.d.ts.map +1 -0
  106. package/dist/shared/proto/online/disconnect-message.js +15 -0
  107. package/dist/shared/proto/online/frame-set.d.ts +9 -0
  108. package/dist/shared/proto/online/frame-set.d.ts.map +1 -0
  109. package/dist/shared/proto/online/frame-set.js +23 -0
  110. package/dist/shared/proto/online/index.d.ts +9 -0
  111. package/dist/shared/proto/online/index.d.ts.map +1 -0
  112. package/dist/shared/proto/online/index.js +24 -0
  113. package/dist/shared/proto/online/new-incomming-connection.d.ts +11 -0
  114. package/dist/shared/proto/online/new-incomming-connection.d.ts.map +1 -0
  115. package/dist/shared/proto/online/new-incomming-connection.js +33 -0
  116. package/dist/shared/proto/types/address.d.ts +12 -0
  117. package/dist/shared/proto/types/address.d.ts.map +1 -0
  118. package/dist/shared/proto/types/address.js +61 -0
  119. package/dist/shared/proto/types/frame.d.ts +23 -0
  120. package/dist/shared/proto/types/frame.d.ts.map +1 -0
  121. package/dist/shared/proto/types/frame.js +119 -0
  122. package/dist/{proto/packets → shared/proto}/types/index.d.ts +0 -2
  123. package/dist/shared/proto/types/index.d.ts.map +1 -0
  124. package/dist/{proto/packets → shared/proto}/types/index.js +0 -2
  125. package/dist/shared/proto/types/magic.d.ts +7 -0
  126. package/dist/shared/proto/types/magic.d.ts.map +1 -0
  127. package/dist/shared/proto/types/magic.js +15 -0
  128. package/dist/shared/proto/types/mtu.d.ts +7 -0
  129. package/dist/shared/proto/types/mtu.d.ts.map +1 -0
  130. package/dist/shared/proto/types/mtu.js +13 -0
  131. package/dist/tests/client-connect.d.ts +2 -0
  132. package/dist/tests/client-connect.d.ts.map +1 -0
  133. package/dist/tests/client-connect.js +32 -0
  134. package/dist/tests/client-once.d.ts +2 -0
  135. package/dist/tests/client-once.d.ts.map +1 -0
  136. package/dist/tests/client-once.js +11 -0
  137. package/dist/tests/server-listen.d.ts +2 -0
  138. package/dist/tests/server-listen.d.ts.map +1 -0
  139. package/dist/tests/server-listen.js +5 -0
  140. package/package.json +8 -8
  141. package/bun.lock +0 -67
  142. package/dist/client/client-events.d.ts +0 -23
  143. package/dist/client/client-events.d.ts.map +0 -1
  144. package/dist/client/client-options.d.ts +0 -13
  145. package/dist/client/client-options.d.ts.map +0 -1
  146. package/dist/client/client-options.js +0 -14
  147. package/dist/client/client_options.d.ts +0 -10
  148. package/dist/client/client_options.d.ts.map +0 -1
  149. package/dist/client/client_options.js +0 -11
  150. package/dist/client/framer.d.ts +0 -56
  151. package/dist/client/framer.d.ts.map +0 -1
  152. package/dist/client/framer.js +0 -467
  153. package/dist/proto/decorators/create.d.ts +0 -8
  154. package/dist/proto/decorators/create.d.ts.map +0 -1
  155. package/dist/proto/decorators/create.js +0 -77
  156. package/dist/proto/decorators/index.d.ts +0 -3
  157. package/dist/proto/decorators/index.d.ts.map +0 -1
  158. package/dist/proto/decorators/serialize.d.ts +0 -4
  159. package/dist/proto/decorators/serialize.d.ts.map +0 -1
  160. package/dist/proto/decorators/serialize.js +0 -12
  161. package/dist/proto/enums/flags.d.ts +0 -7
  162. package/dist/proto/enums/flags.d.ts.map +0 -1
  163. package/dist/proto/enums/flags.js +0 -10
  164. package/dist/proto/enums/index.d.ts +0 -6
  165. package/dist/proto/enums/index.d.ts.map +0 -1
  166. package/dist/proto/enums/packet.d.ts +0 -122
  167. package/dist/proto/enums/packet.d.ts.map +0 -1
  168. package/dist/proto/enums/packet.js +0 -125
  169. package/dist/proto/enums/priority.d.ts +0 -5
  170. package/dist/proto/enums/priority.d.ts.map +0 -1
  171. package/dist/proto/enums/priority.js +0 -8
  172. package/dist/proto/enums/reliability.d.ts.map +0 -1
  173. package/dist/proto/enums/status.d.ts +0 -7
  174. package/dist/proto/enums/status.d.ts.map +0 -1
  175. package/dist/proto/enums/status.js +0 -10
  176. package/dist/proto/index.d.ts +0 -5
  177. package/dist/proto/index.d.ts.map +0 -1
  178. package/dist/proto/packets/ack.d.ts +0 -10
  179. package/dist/proto/packets/ack.d.ts.map +0 -1
  180. package/dist/proto/packets/base-packet.d.ts +0 -26
  181. package/dist/proto/packets/base-packet.d.ts.map +0 -1
  182. package/dist/proto/packets/base-packet.js +0 -37
  183. package/dist/proto/packets/connected-ping.d.ts +0 -5
  184. package/dist/proto/packets/connected-ping.d.ts.map +0 -1
  185. package/dist/proto/packets/connected-ping.js +0 -27
  186. package/dist/proto/packets/connected-pong.d.ts +0 -6
  187. package/dist/proto/packets/connected-pong.d.ts.map +0 -1
  188. package/dist/proto/packets/connected-pong.js +0 -32
  189. package/dist/proto/packets/connection-request-accepted.d.ts +0 -10
  190. package/dist/proto/packets/connection-request-accepted.d.ts.map +0 -1
  191. package/dist/proto/packets/connection-request-accepted.js +0 -48
  192. package/dist/proto/packets/connection-request.d.ts +0 -7
  193. package/dist/proto/packets/connection-request.d.ts.map +0 -1
  194. package/dist/proto/packets/connection-request.js +0 -37
  195. package/dist/proto/packets/disconnect.d.ts +0 -5
  196. package/dist/proto/packets/disconnect.d.ts.map +0 -1
  197. package/dist/proto/packets/disconnect.js +0 -17
  198. package/dist/proto/packets/frame.d.ts +0 -1
  199. package/dist/proto/packets/frame.d.ts.map +0 -1
  200. package/dist/proto/packets/frame.js +0 -1
  201. package/dist/proto/packets/frameset.d.ts +0 -11
  202. package/dist/proto/packets/frameset.d.ts.map +0 -1
  203. package/dist/proto/packets/frameset.js +0 -37
  204. package/dist/proto/packets/incompatible-protocol-version.d.ts +0 -8
  205. package/dist/proto/packets/incompatible-protocol-version.d.ts.map +0 -1
  206. package/dist/proto/packets/incompatible-protocol-version.js +0 -38
  207. package/dist/proto/packets/index.d.ts +0 -19
  208. package/dist/proto/packets/index.d.ts.map +0 -1
  209. package/dist/proto/packets/index.js +0 -34
  210. package/dist/proto/packets/nack.d.ts +0 -8
  211. package/dist/proto/packets/nack.d.ts.map +0 -1
  212. package/dist/proto/packets/nack.js +0 -88
  213. package/dist/proto/packets/new-incoming-connection.d.ts +0 -9
  214. package/dist/proto/packets/new-incoming-connection.d.ts.map +0 -1
  215. package/dist/proto/packets/new-incoming-connection.js +0 -43
  216. package/dist/proto/packets/open-connection-reply-one.d.ts +0 -8
  217. package/dist/proto/packets/open-connection-reply-one.d.ts.map +0 -1
  218. package/dist/proto/packets/open-connection-reply-one.js +0 -43
  219. package/dist/proto/packets/open-connection-reply-two.d.ts +0 -10
  220. package/dist/proto/packets/open-connection-reply-two.d.ts.map +0 -1
  221. package/dist/proto/packets/open-connection-reply-two.js +0 -48
  222. package/dist/proto/packets/open-connection-request-one.d.ts +0 -7
  223. package/dist/proto/packets/open-connection-request-one.d.ts.map +0 -1
  224. package/dist/proto/packets/open-connection-request-one.js +0 -38
  225. package/dist/proto/packets/open-connection-request-two.d.ts +0 -9
  226. package/dist/proto/packets/open-connection-request-two.d.ts.map +0 -1
  227. package/dist/proto/packets/open-connection-request-two.js +0 -43
  228. package/dist/proto/packets/types/address.d.ts +0 -48
  229. package/dist/proto/packets/types/address.d.ts.map +0 -1
  230. package/dist/proto/packets/types/address.js +0 -99
  231. package/dist/proto/packets/types/data-type.d.ts +0 -21
  232. package/dist/proto/packets/types/data-type.d.ts.map +0 -1
  233. package/dist/proto/packets/types/data-type.js +0 -29
  234. package/dist/proto/packets/types/frame.d.ts +0 -23
  235. package/dist/proto/packets/types/frame.d.ts.map +0 -1
  236. package/dist/proto/packets/types/frame.js +0 -94
  237. package/dist/proto/packets/types/index.d.ts.map +0 -1
  238. package/dist/proto/packets/types/magic.d.ts +0 -7
  239. package/dist/proto/packets/types/magic.d.ts.map +0 -1
  240. package/dist/proto/packets/types/magic.js +0 -14
  241. package/dist/proto/packets/types/mtu.d.ts +0 -9
  242. package/dist/proto/packets/types/mtu.d.ts.map +0 -1
  243. package/dist/proto/packets/types/mtu.js +0 -18
  244. package/dist/proto/packets/types/sys-address.d.ts +0 -11
  245. package/dist/proto/packets/types/sys-address.d.ts.map +0 -1
  246. package/dist/proto/packets/types/sys-address.js +0 -32
  247. package/dist/proto/packets/unconnected-ping.d.ts +0 -7
  248. package/dist/proto/packets/unconnected-ping.d.ts.map +0 -1
  249. package/dist/proto/packets/unconnected-ping.js +0 -38
  250. package/dist/proto/packets/unconnected-pong.d.ts +0 -8
  251. package/dist/proto/packets/unconnected-pong.d.ts.map +0 -1
  252. package/dist/proto/packets/unconnected-pong.js +0 -43
  253. package/dist/proto/types/advertisement.d.ts.map +0 -1
  254. package/dist/proto/types/index.d.ts +0 -3
  255. package/dist/proto/types/index.d.ts.map +0 -1
  256. package/dist/proto/types/valid.d.ts +0 -4
  257. package/dist/proto/types/valid.d.ts.map +0 -1
  258. package/dist/server/server-events.d.ts +0 -9
  259. package/dist/server/server-events.d.ts.map +0 -1
  260. package/dist/server/server-options.d.ts +0 -26
  261. package/dist/server/server-options.d.ts.map +0 -1
  262. package/dist/server/server-options.js +0 -20
  263. package/dist/tests/client.d.ts +0 -2
  264. package/dist/tests/client.d.ts.map +0 -1
  265. package/dist/tests/client.js +0 -15
  266. package/dist/tests/localhost.d.ts +0 -2
  267. package/dist/tests/localhost.d.ts.map +0 -1
  268. package/dist/tests/localhost.js +0 -34
  269. package/dist/tests/server.d.ts +0 -2
  270. package/dist/tests/server.d.ts.map +0 -1
  271. package/dist/tests/server.js +0 -32
  272. package/dist/tests/test.d.ts +0 -2
  273. package/dist/tests/test.d.ts.map +0 -1
  274. package/dist/tests/test.js +0 -49
  275. package/dist/utils/Logger.d.ts.map +0 -1
  276. package/dist/utils/decorators.d.ts +0 -2
  277. package/dist/utils/decorators.d.ts.map +0 -1
  278. package/dist/utils/decorators.js +0 -17
  279. package/dist/utils/index.d.ts +0 -2
  280. package/dist/utils/index.d.ts.map +0 -1
  281. /package/dist/client/{client-events.js → types/client-events.js} +0 -0
  282. /package/dist/{proto/types/valid.js → server/types/connection-events.js} +0 -0
  283. /package/dist/server/{server-events.js → types/server-events.js} +0 -0
  284. /package/dist/{utils/Logger.js → shared/logger.js} +0 -0
  285. /package/dist/{proto → shared/proto}/enums/reliability.d.ts +0 -0
  286. /package/dist/{proto → shared/proto}/enums/reliability.js +0 -0
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Frame = exports.SplitFlag = void 0;
4
+ const binarystream_1 = require("@serenityjs/binarystream");
5
+ const enums_1 = require("../enums");
6
+ exports.SplitFlag = 0x10;
7
+ class Frame {
8
+ reliability;
9
+ reliableFrameIndex;
10
+ sequenceFrameIndex;
11
+ orderedFrameIndex;
12
+ orderChannel;
13
+ splitFrameIndex;
14
+ splitSize;
15
+ splitId;
16
+ payload;
17
+ static write(stream, frames) {
18
+ for (const frame of frames) {
19
+ const isReliable = frame.isReliable();
20
+ const isSequenced = frame.isSequenced();
21
+ const isOrdered = frame.isOrdered();
22
+ const isSplit = frame.isSplit();
23
+ const reliability = (frame.reliability << 5) | (isSplit ? exports.SplitFlag : 0);
24
+ const little = { endian: binarystream_1.Endianness.Little };
25
+ binarystream_1.Uint8.write(stream, reliability);
26
+ binarystream_1.Uint16.write(stream, frame.payload.byteLength << 3);
27
+ if (isReliable)
28
+ binarystream_1.Uint24.write(stream, frame.reliableFrameIndex, little);
29
+ if (isSequenced)
30
+ binarystream_1.Uint24.write(stream, frame.sequenceFrameIndex, little);
31
+ if (isOrdered) {
32
+ binarystream_1.Uint24.write(stream, frame.orderedFrameIndex, little);
33
+ binarystream_1.Uint8.write(stream, frame.orderChannel);
34
+ }
35
+ if (isSplit) {
36
+ binarystream_1.Uint32.write(stream, frame.splitSize);
37
+ binarystream_1.Uint16.write(stream, frame.splitId);
38
+ binarystream_1.Uint32.write(stream, frame.splitFrameIndex);
39
+ }
40
+ stream.write(frame.payload);
41
+ }
42
+ }
43
+ static read(stream) {
44
+ const frames = [];
45
+ while (!stream.feof()) {
46
+ const frame = new Frame();
47
+ const header = binarystream_1.Uint8.read(stream);
48
+ const reliability = (header & 0xe0) >> 5;
49
+ const split = (header & exports.SplitFlag) !== 0;
50
+ const length = Math.ceil(binarystream_1.Uint16.read(stream) / 8);
51
+ frame.reliability = reliability;
52
+ const little = { endian: binarystream_1.Endianness.Little };
53
+ const isReliable = frame.isReliable();
54
+ const isSequenced = frame.isSequenced();
55
+ const isOrdered = frame.isOrdered();
56
+ if (isReliable)
57
+ frame.reliableFrameIndex = binarystream_1.Uint24.read(stream, little);
58
+ if (isSequenced)
59
+ frame.sequenceFrameIndex = binarystream_1.Uint24.read(stream, little);
60
+ if (isOrdered) {
61
+ frame.orderedFrameIndex = binarystream_1.Uint24.read(stream, little);
62
+ frame.orderChannel = binarystream_1.Uint8.read(stream);
63
+ }
64
+ if (split) {
65
+ frame.splitSize = binarystream_1.Uint32.read(stream);
66
+ frame.splitId = binarystream_1.Uint16.read(stream);
67
+ frame.splitFrameIndex = binarystream_1.Uint32.read(stream);
68
+ }
69
+ frame.payload = stream.read(length);
70
+ frames.push(frame);
71
+ }
72
+ return frames;
73
+ }
74
+ isSplit() {
75
+ return this.splitSize > 0;
76
+ }
77
+ isReliable() {
78
+ const values = [
79
+ enums_1.Reliability.Reliable,
80
+ enums_1.Reliability.ReliableOrdered,
81
+ enums_1.Reliability.ReliableSequenced,
82
+ enums_1.Reliability.ReliableWithAckReceipt,
83
+ enums_1.Reliability.ReliableOrderedWithAckReceipt,
84
+ ];
85
+ return values.includes(this.reliability);
86
+ }
87
+ isSequenced() {
88
+ const values = [
89
+ enums_1.Reliability.ReliableSequenced,
90
+ enums_1.Reliability.UnreliableSequenced,
91
+ ];
92
+ return values.includes(this.reliability);
93
+ }
94
+ isOrdered() {
95
+ const values = [
96
+ enums_1.Reliability.UnreliableSequenced,
97
+ enums_1.Reliability.ReliableOrdered,
98
+ enums_1.Reliability.ReliableSequenced,
99
+ enums_1.Reliability.ReliableOrderedWithAckReceipt,
100
+ ];
101
+ return values.includes(this.reliability);
102
+ }
103
+ isOrderExclusive() {
104
+ const values = [
105
+ enums_1.Reliability.ReliableOrdered,
106
+ enums_1.Reliability.ReliableOrderedWithAckReceipt,
107
+ ];
108
+ return values.includes(this.reliability);
109
+ }
110
+ getByteLength() {
111
+ return (3 +
112
+ this.payload.byteLength +
113
+ (this.isReliable() ? 3 : 0) +
114
+ (this.isSequenced() ? 3 : 0) +
115
+ (this.isOrdered() ? 4 : 0) +
116
+ (this.isSplit() ? 10 : 0));
117
+ }
118
+ }
119
+ exports.Frame = Frame;
@@ -1,7 +1,5 @@
1
- export * from "./data-type";
2
1
  export * from "./magic";
3
2
  export * from "./mtu";
4
3
  export * from "./address";
5
4
  export * from "./frame";
6
- export * from "./sys-address";
7
5
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
@@ -14,9 +14,7 @@ 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("./data-type"), exports);
18
17
  __exportStar(require("./magic"), exports);
19
18
  __exportStar(require("./mtu"), exports);
20
19
  __exportStar(require("./address"), exports);
21
20
  __exportStar(require("./frame"), exports);
22
- __exportStar(require("./sys-address"), exports);
@@ -0,0 +1,7 @@
1
+ import type { BinaryStream } from "@serenityjs/binarystream";
2
+ export declare class Magic {
3
+ static write(stream: BinaryStream): void;
4
+ static read(stream: BinaryStream): Buffer;
5
+ nothingItJustIgnoresANoStaticClassLint(): void;
6
+ }
7
+ //# sourceMappingURL=magic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"magic.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/types/magic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAI7D,qBAAa,KAAK;IACjB,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,YAAY;IAIjC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM;IAKzC,sCAAsC;CACtC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Magic = void 0;
4
+ const magic = Buffer.from("00ffff00fefefefefdfdfdfd12345678", "hex");
5
+ class Magic {
6
+ static write(stream) {
7
+ stream.write(magic);
8
+ }
9
+ static read(stream) {
10
+ const readMagic = stream.read(16);
11
+ return readMagic;
12
+ }
13
+ nothingItJustIgnoresANoStaticClassLint() { }
14
+ }
15
+ exports.Magic = Magic;
@@ -0,0 +1,7 @@
1
+ import type { BinaryStream } from "@serenityjs/binarystream";
2
+ export declare class MTU {
3
+ static write(stream: BinaryStream, mtu: number): void;
4
+ static read(stream: BinaryStream): number;
5
+ nothingItJustIgnoresANoStaticClassLint(): void;
6
+ }
7
+ //# sourceMappingURL=mtu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mtu.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/types/mtu.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,qBAAa,GAAG;IACf,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM;IAI9C,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM;IAIzC,sCAAsC;CACtC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MTU = void 0;
4
+ class MTU {
5
+ static write(stream, mtu) {
6
+ stream.write(Buffer.alloc(mtu - stream.getBuffer().length));
7
+ }
8
+ static read(stream) {
9
+ return stream.buffer.byteLength;
10
+ }
11
+ nothingItJustIgnoresANoStaticClassLint() { }
12
+ }
13
+ exports.MTU = MTU;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=client-connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-connect.d.ts","sourceRoot":"","sources":["../../src/tests/client-connect.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const client_1 = require("../client");
4
+ const logger_1 = require("../shared/logger");
5
+ async function runBenchmark(iterations) {
6
+ logger_1.Logger.info(`§bStarting connection benchmark for ${iterations} iterations...§r`);
7
+ const connectionTimes = [];
8
+ for (let i = 0; i < iterations; i++) {
9
+ const time = Date.now();
10
+ const client = new client_1.Client({});
11
+ client.on("unconnectedPong", (packet) => {
12
+ logger_1.Logger.debug("unconnectedPong packet:", packet);
13
+ });
14
+ const connectionPromise = new Promise((resolve) => {
15
+ client.on("connect", () => {
16
+ const time2 = Date.now();
17
+ const timeDiff = time2 - time;
18
+ logger_1.Logger.info(`§aConnection attempt ${i + 1}/${iterations}: Connected in ${timeDiff}ms§r`);
19
+ resolve(timeDiff);
20
+ });
21
+ });
22
+ client.connect();
23
+ const connectionTime = await connectionPromise;
24
+ connectionTimes.push(connectionTime);
25
+ }
26
+ logger_1.Logger.warn("\n§e--- Benchmark Results ---§r");
27
+ logger_1.Logger.info("All Connection Times:", connectionTimes);
28
+ const totalTime = connectionTimes.reduce((sum, time) => sum + time, 0);
29
+ const averageTime = totalTime / iterations;
30
+ logger_1.Logger.info(`Average connection time over ${iterations} attempts: §d${averageTime.toFixed(2)}ms§r`);
31
+ }
32
+ runBenchmark(10);
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=client-once.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-once.d.ts","sourceRoot":"","sources":["../../src/tests/client-once.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const client_1 = require("../client");
4
+ const client = new client_1.Client();
5
+ client.on("unconnectedPong", (packet) => {
6
+ console.log(packet);
7
+ });
8
+ const time = Date.now();
9
+ client.connect().then(() => {
10
+ console.log(`Time taked ${Date.now() - time}ms`);
11
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=server-listen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-listen.d.ts","sourceRoot":"","sources":["../../src/tests/server-listen.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const server_1 = require("../server");
4
+ const server = new server_1.Server();
5
+ server.listen();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanctumterra/raknet",
3
- "version": "1.3.79",
3
+ "version": "1.4.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "commonjs",
@@ -9,20 +9,20 @@
9
9
  "watch": "tsc --watch",
10
10
  "format": "npx @biomejs/biome format ./src",
11
11
  "lint": "npx @biomejs/biome lint ./src",
12
- "lint-write": "npx @biomejs/biome lint --write ./src",
13
- "format-write": "npx @biomejs/biome format --write ./src"
12
+ "lint:write": "npx @biomejs/biome lint --write ./src",
13
+ "format:write": "npx @biomejs/biome format --write ./src"
14
14
  },
15
15
  "keywords": [],
16
16
  "author": "",
17
17
  "license": "ISC",
18
18
  "dependencies": {
19
- "@serenityjs/binarystream": "2.7.3",
20
- "@serenityjs/emitter": "^0.5.2",
21
- "@serenityjs/protocol": "^0.6.4",
22
- "reflect-metadata": "^0.2.2"
19
+ "@sanctumterra/raknet": ".",
20
+ "@serenityjs/binarystream": "^3.0.10"
23
21
  },
24
22
  "devDependencies": {
23
+ "@types/bun": "^1.2.21",
24
+ "typescript": "^5.9.2",
25
25
  "@biomejs/biome": "^1.9.4",
26
- "@types/node": "^22.8.0"
26
+ "@types/node": "^24.3.0"
27
27
  }
28
28
  }
package/bun.lock DELETED
@@ -1,67 +0,0 @@
1
- {
2
- "lockfileVersion": 1,
3
- "workspaces": {
4
- "": {
5
- "name": "@sanctumterra/raknet",
6
- "dependencies": {
7
- "@serenityjs/binarystream": "^2.6.6",
8
- "@serenityjs/emitter": "^0.5.2",
9
- "@serenityjs/protocol": "^0.6.4",
10
- "reflect-metadata": "^0.2.2",
11
- },
12
- "devDependencies": {
13
- "@biomejs/biome": "^1.9.4",
14
- "@types/node": "^22.8.0",
15
- },
16
- },
17
- },
18
- "packages": {
19
- "@biomejs/biome": ["@biomejs/biome@1.9.4", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "1.9.4", "@biomejs/cli-darwin-x64": "1.9.4", "@biomejs/cli-linux-arm64": "1.9.4", "@biomejs/cli-linux-arm64-musl": "1.9.4", "@biomejs/cli-linux-x64": "1.9.4", "@biomejs/cli-linux-x64-musl": "1.9.4", "@biomejs/cli-win32-arm64": "1.9.4", "@biomejs/cli-win32-x64": "1.9.4" }, "bin": { "biome": "bin/biome" } }, "sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog=="],
20
-
21
- "@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@1.9.4", "", { "os": "darwin", "cpu": "arm64" }, "sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw=="],
22
-
23
- "@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@1.9.4", "", { "os": "darwin", "cpu": "x64" }, "sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg=="],
24
-
25
- "@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@1.9.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g=="],
26
-
27
- "@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@1.9.4", "", { "os": "linux", "cpu": "arm64" }, "sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA=="],
28
-
29
- "@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@1.9.4", "", { "os": "linux", "cpu": "x64" }, "sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg=="],
30
-
31
- "@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@1.9.4", "", { "os": "linux", "cpu": "x64" }, "sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg=="],
32
-
33
- "@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@1.9.4", "", { "os": "win32", "cpu": "arm64" }, "sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg=="],
34
-
35
- "@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@1.9.4", "", { "os": "win32", "cpu": "x64" }, "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA=="],
36
-
37
- "@serenityjs/binarystream": ["@serenityjs/binarystream@2.7.0", "", { "optionalDependencies": { "@serenityjs/binarystream-darwin-arm64": "2.7.0", "@serenityjs/binarystream-darwin-x64": "2.7.0", "@serenityjs/binarystream-linux-x64-gnu": "2.7.0", "@serenityjs/binarystream-win32-x64-msvc": "2.7.0" } }, "sha512-aIWTRqy3Z5mf9qbLiE7sjM96+PKXsJqs4tURe5VlnI5fauNlFIwUUBXGyrR2PiqBSOp8DSjmP1XfO49GP4hdEg=="],
38
-
39
- "@serenityjs/binarystream-darwin-arm64": ["@serenityjs/binarystream-darwin-arm64@2.7.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-i1MUyRLT6zNWSTOIb5eALFnSxEFmbM+nc/yw5ooqzAOM4qtr/jBrolHyEm157AU8+7ngnkBn9T94Z4zVYJGBhg=="],
40
-
41
- "@serenityjs/binarystream-darwin-x64": ["@serenityjs/binarystream-darwin-x64@2.7.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-hm2G3dlR4meGp2MqCmdWWPqTZxcsGdT4P/cg1i5Y74BdG9F9CYojvHPN9jaq8fY+ViqBz0hzPvrKPIPEMwBDHQ=="],
42
-
43
- "@serenityjs/binarystream-linux-x64-gnu": ["@serenityjs/binarystream-linux-x64-gnu@2.7.0", "", { "os": "linux", "cpu": "x64" }, "sha512-C2HgD+coQtlpIxnkpRObE38+rU2xVqsvRRZPcSxpkAzdPaiyVehkF7VZx0cWAZPiLZEZifNDTQV3tQlgfp4USg=="],
44
-
45
- "@serenityjs/binarystream-win32-x64-msvc": ["@serenityjs/binarystream-win32-x64-msvc@2.7.0", "", { "os": "win32", "cpu": "x64" }, "sha512-VozM9uyBdQQJXl5Cz9zdn2dA6jOpkgzWJHjgop63FSpVAllykMKbd2WU2ZpEbLy0dTScmND2suXcqiPeU5Jrwg=="],
46
-
47
- "@serenityjs/emitter": ["@serenityjs/emitter@0.5.2", "", {}, "sha512-x+tYqmCbOzSI0wo/0t6Scj5OU883RtTUZ6b0jfhymO0E5GEF1RkWI/4eEGcHUWMtuFDbPtb2pQynPNbt4R4XCQ=="],
48
-
49
- "@serenityjs/logger": ["@serenityjs/logger@0.8.0", "", { "dependencies": { "colorette": "2.0.20", "moment": "2.30.1" } }, "sha512-GSCbCNYmeSIAPAX0W+TKyB7zTtd9BSg+s/hxqK6JMpMMq679YPKkvv7pmQKme2Da/c2czIvNvbh4x7HGx15grQ=="],
50
-
51
- "@serenityjs/nbt": ["@serenityjs/nbt@0.8.0", "", { "dependencies": { "@serenityjs/binarystream": "^2.7.0" } }, "sha512-+4l3xwR33+UHTo5+cJD1q+Q/jTIvhbvgsGr5uUaojYaUfpf7UnHcew3LsiSXhzTtCC7VR90lv2XUvq9lDhAhJA=="],
52
-
53
- "@serenityjs/protocol": ["@serenityjs/protocol@0.6.4", "", { "dependencies": { "@serenityjs/binarystream": "2.7.0", "@serenityjs/nbt": "*", "@serenityjs/raknet": "*" } }, "sha512-tTeB2LmVxbQOOOadUetomjhJS3TO8GzqXBwdHDnrkhivhF8fJR27bUEYL4ZNvKB9nyuXpKxQJiXaatkHq6UroA=="],
54
-
55
- "@serenityjs/raknet": ["@serenityjs/raknet@0.8.0", "", { "dependencies": { "@serenityjs/binarystream": "^2.7.0", "@serenityjs/emitter": "*", "@serenityjs/logger": "*", "@serenityjs/nbt": "*", "reflect-metadata": "0.2.2" } }, "sha512-A7xOF6nhOljUD/yUrvNfXVAJhdVV+SC4rzBclexcDaLaxn5EqNQP4BFytKSsTb/v15wvlfY+600eBF4/qm9G+Q=="],
56
-
57
- "@types/node": ["@types/node@22.15.13", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-mkmz+UBGCF/ssSObTp1McwQEvIjO2hUnVvZzck61l0su7btUill8OSvzA4N62+AtkJgMhiniyD+wEL5kocZaEA=="],
58
-
59
- "colorette": ["colorette@2.0.20", "", {}, "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w=="],
60
-
61
- "moment": ["moment@2.30.1", "", {}, "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how=="],
62
-
63
- "reflect-metadata": ["reflect-metadata@0.2.2", "", {}, "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q=="],
64
-
65
- "undici-types": ["undici-types@6.21.0", "", {}, "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ=="],
66
- }
67
- }
@@ -1,23 +0,0 @@
1
- import type { Ack, Advertisement, ConnectedPing, ConnectedPong, ConnectionRequest, ConnectionRequestAccepted, NewIncomingConnection, OpenConnectionReplyOne, OpenConnectionReplyTwo, OpenConnectionRequestOne, OpenConnectionRequestTwo, UnconnectedPing, UnconnectedPong } from "../proto";
2
- import type { Frameset } from "../proto/packets/frameset";
3
- export interface ClientEvents {
4
- "open-connection-reply-one": [OpenConnectionReplyOne];
5
- "open-connection-reply-two": [OpenConnectionReplyTwo];
6
- "open-connection-request-one": [OpenConnectionRequestOne];
7
- "open-connection-request-two": [OpenConnectionRequestTwo];
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: [Advertisement];
21
- tick: [];
22
- }
23
- //# sourceMappingURL=client-events.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-events.d.ts","sourceRoot":"","sources":["../../src/client/client-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,GAAG,EACH,aAAa,EACb,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,WAAW,YAAY;IAC5B,2BAA2B,EAAE,CAAC,sBAAsB,CAAC,CAAC;IACtD,2BAA2B,EAAE,CAAC,sBAAsB,CAAC,CAAC;IACtD,6BAA6B,EAAE,CAAC,wBAAwB,CAAC,CAAC;IAC1D,6BAA6B,EAAE,CAAC,wBAAwB,CAAC,CAAC;IAC1D,kBAAkB,EAAE,CAAC,eAAe,CAAC,CAAC;IACtC,kBAAkB,EAAE,CAAC,eAAe,CAAC,CAAC;IACtC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;IACrB,gBAAgB,EAAE,CAAC,aAAa,CAAC,CAAC;IAClC,gBAAgB,EAAE,CAAC,aAAa,CAAC,CAAC;IAClC,oBAAoB,EAAE,CAAC,iBAAiB,CAAC,CAAC;IAC1C,6BAA6B,EAAE,CAAC,yBAAyB,CAAC,CAAC;IAC3D,yBAAyB,EAAE,CAAC,qBAAqB,CAAC,CAAC;IACnD,YAAY,EAAE,CAAC,MAAM,CAAC,CAAC;IACvB,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IACX,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;IACf,KAAK,EAAE,EAAE,CAAC;IACV,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC;IACzB,IAAI,EAAE,EAAE,CAAC;CACT"}
@@ -1,13 +0,0 @@
1
- type ClientOptions = {
2
- address: string;
3
- port: number;
4
- protocolVersion: number;
5
- mtuSize: number;
6
- clientId: bigint;
7
- debug: boolean;
8
- timeout: number;
9
- loggerDisabled: boolean;
10
- };
11
- declare const defaultClientOptions: ClientOptions;
12
- export { type ClientOptions, defaultClientOptions };
13
- //# sourceMappingURL=client-options.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-options.d.ts","sourceRoot":"","sources":["../../src/client/client-options.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,QAAA,MAAM,oBAAoB,EAAE,aAS3B,CAAC;AAEF,OAAO,EAAE,KAAK,aAAa,EAAE,oBAAoB,EAAE,CAAC"}
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultClientOptions = void 0;
4
- const defaultClientOptions = {
5
- address: "127.0.0.1",
6
- port: 19132,
7
- protocolVersion: 11,
8
- mtuSize: 1492,
9
- clientId: BigInt(Math.floor(Math.random() * 1000000000000000000)),
10
- debug: false,
11
- timeout: 5000,
12
- loggerDisabled: false,
13
- };
14
- exports.defaultClientOptions = defaultClientOptions;
@@ -1,10 +0,0 @@
1
- type ClientOptions = {
2
- address: string;
3
- port: number;
4
- mtuSize: number;
5
- debug: boolean;
6
- timeout: number;
7
- };
8
- declare const defaultClientOptions: ClientOptions;
9
- export { type ClientOptions, defaultClientOptions };
10
- //# sourceMappingURL=client_options.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client_options.d.ts","sourceRoot":"","sources":["../../src/client/client_options.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,QAAA,MAAM,oBAAoB,EAAE,aAM3B,CAAC;AAEF,OAAO,EAAE,KAAK,aAAa,EAAE,oBAAoB,EAAE,CAAC"}
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultClientOptions = void 0;
4
- const defaultClientOptions = {
5
- address: "127.0.0.1",
6
- port: 19132,
7
- mtuSize: 1492,
8
- debug: false,
9
- timeout: 5000,
10
- };
11
- exports.defaultClientOptions = defaultClientOptions;
@@ -1,56 +0,0 @@
1
- import { Frame, Priority } from "../proto";
2
- import { Frameset } from "../proto";
3
- import type { Client } from "./client";
4
- import type { RemoteInfo } from "node:dgram";
5
- interface QueuedFrame {
6
- frame: Frame;
7
- timestamp: number;
8
- }
9
- export declare class Framer {
10
- private client;
11
- private lastInputSequence;
12
- private receivedFrameSequences;
13
- private lostFrameSequences;
14
- private inputHighestSequenceIndex;
15
- private inputOrderIndex;
16
- protected inputOrderingQueue: Array<Map<number, QueuedFrame>>;
17
- protected readonly fragmentsQueue: Map<number, {
18
- fragments: Map<number, Frame>;
19
- timestamp: number;
20
- }>;
21
- outputOrderIndex: number[];
22
- outputSequenceIndex: number[];
23
- outputFrameQueue: Frameset;
24
- protected outputSequence: number;
25
- protected outputSplitIndex: number;
26
- protected outputReliableIndex: number;
27
- outputFrames: Frame[];
28
- private outputFramesByteLength;
29
- outputBackup: Map<number, Frame[]>;
30
- _tickCount: number;
31
- private mtuDiff;
32
- private readonly BATCH_SIZE;
33
- private readonly MAX_BATCH_INTERVAL;
34
- private lastBatchTime;
35
- private readonly ORDERING_QUEUE_TIMEOUT;
36
- constructor(client: Client);
37
- tick(): void;
38
- private processBatchedAcksAndNacks;
39
- private processBatchedOrderedFrames;
40
- incomingMessage(payload: Buffer, rinfo: RemoteInfo): void;
41
- private processFrame;
42
- handle(frameSet: Frameset): void;
43
- private handleFrame;
44
- private handleOrdered;
45
- private processOrderedFrames;
46
- private handleSequenced;
47
- private handleSplit;
48
- private reassembleAndProcessFragment;
49
- frameAndSend(payload: Buffer, priority?: Priority): void;
50
- sendFrame(frame: Frame, priority: Priority): void;
51
- private createSplitFrame;
52
- private queueFrame;
53
- sendQueue(amount: number): void;
54
- }
55
- export {};
56
- //# sourceMappingURL=framer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"framer.d.ts","sourceRoot":"","sources":["../../src/client/framer.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,EAGL,QAAQ,EAUR,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAS7C,UAAU,WAAW;IACpB,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,MAAM;IAClB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,iBAAiB,CAAM;IAC/B,OAAO,CAAC,sBAAsB,CAA0B;IACxD,OAAO,CAAC,kBAAkB,CAA0B;IACpD,OAAO,CAAC,yBAAyB,CAAmC;IACpE,OAAO,CAAC,eAAe,CAAmC;IAC1D,SAAS,CAAC,kBAAkB,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAG3D;IACF,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,GAAG,CACrC,MAAM,EACN;QAAE,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CACpD,CAAa;IAEP,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,gBAAgB,EAAE,QAAQ,CAAC;IAClC,SAAS,CAAC,cAAc,SAAK;IAC7B,SAAS,CAAC,gBAAgB,SAAK;IAC/B,SAAS,CAAC,mBAAmB,SAAK;IAC3B,YAAY,EAAE,KAAK,EAAE,CAAM;IAClC,OAAO,CAAC,sBAAsB,CAAK;IAC5B,YAAY,uBAA8B;IAC1C,UAAU,SAAK;IAEtB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAM;IACjC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAM;IACzC,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAO;gBAElC,MAAM,EAAE,MAAM;IASnB,IAAI;IAmCX,OAAO,CAAC,0BAA0B;IAoBlC,OAAO,CAAC,2BAA2B;IAiC5B,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU;IAoEzD,OAAO,CAAC,YAAY;IA6Eb,MAAM,CAAC,QAAQ,EAAE,QAAQ;IA0DhC,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,oBAAoB;IAqB5B,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,WAAW;IAenB,OAAO,CAAC,4BAA4B;IA2B7B,YAAY,CAClB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,QAA0B,GAClC,IAAI;IAOA,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAiCxD,OAAO,CAAC,gBAAgB;IAsBxB,OAAO,CAAC,UAAU;IAqBX,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CA6BtC"}