@sanctumterra/raknet 1.3.80 → 1.4.1

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 (276) hide show
  1. package/README.md +1 -1
  2. package/dist/client/client.d.ts +19 -20
  3. package/dist/client/client.d.ts.map +1 -1
  4. package/dist/client/client.js +139 -184
  5. package/dist/client/types/client-events.d.ts +5 -20
  6. package/dist/client/types/client-events.d.ts.map +1 -1
  7. package/dist/client/types/client-options.d.ts +7 -8
  8. package/dist/client/types/client-options.d.ts.map +1 -1
  9. package/dist/client/types/client-options.js +9 -9
  10. package/dist/client/types/index.d.ts +1 -1
  11. package/dist/client/types/index.d.ts.map +1 -1
  12. package/dist/client/types/index.js +1 -1
  13. package/dist/index.d.ts +1 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -3
  16. package/dist/server/connection.d.ts +20 -59
  17. package/dist/server/connection.d.ts.map +1 -1
  18. package/dist/server/connection.js +53 -365
  19. package/dist/server/index.d.ts +2 -3
  20. package/dist/server/index.d.ts.map +1 -1
  21. package/dist/server/index.js +2 -3
  22. package/dist/server/server.d.ts +11 -18
  23. package/dist/server/server.d.ts.map +1 -1
  24. package/dist/server/server.js +98 -137
  25. package/dist/{proto → server}/types/advertisement.d.ts +1 -1
  26. package/dist/server/types/advertisement.d.ts.map +1 -0
  27. package/dist/{proto → server}/types/advertisement.js +14 -10
  28. package/dist/server/types/connection-events.d.ts +4 -0
  29. package/dist/server/types/connection-events.d.ts.map +1 -0
  30. package/dist/server/types/index.d.ts +5 -0
  31. package/dist/server/types/index.d.ts.map +1 -0
  32. package/dist/{proto → server}/types/index.js +3 -1
  33. package/dist/server/types/server-events.d.ts +7 -0
  34. package/dist/server/types/server-events.d.ts.map +1 -0
  35. package/dist/server/types/server-options.d.ts +12 -0
  36. package/dist/server/types/server-options.d.ts.map +1 -0
  37. package/dist/server/types/server-options.js +14 -0
  38. package/dist/shared/emitter.d.ts +28 -0
  39. package/dist/shared/emitter.d.ts.map +1 -0
  40. package/dist/shared/emitter.js +71 -0
  41. package/dist/shared/index.d.ts +5 -0
  42. package/dist/shared/index.d.ts.map +1 -0
  43. package/dist/{proto/decorators → shared}/index.js +4 -2
  44. package/dist/{utils/Logger.d.ts → shared/logger.d.ts} +1 -1
  45. package/dist/shared/logger.d.ts.map +1 -0
  46. package/dist/shared/network_session.d.ts +34 -0
  47. package/dist/shared/network_session.d.ts.map +1 -0
  48. package/dist/shared/network_session.js +247 -0
  49. package/dist/shared/proto/enums/connectionStatus.d.ts +8 -0
  50. package/dist/shared/proto/enums/connectionStatus.d.ts.map +1 -0
  51. package/dist/shared/proto/enums/connectionStatus.js +11 -0
  52. package/dist/shared/proto/enums/index.d.ts +5 -0
  53. package/dist/shared/proto/enums/index.d.ts.map +1 -0
  54. package/dist/{proto → shared/proto}/enums/index.js +2 -3
  55. package/dist/shared/proto/enums/packets.d.ts +19 -0
  56. package/dist/shared/proto/enums/packets.d.ts.map +1 -0
  57. package/dist/shared/proto/enums/packets.js +23 -0
  58. package/dist/shared/proto/enums/priority.d.ts +6 -0
  59. package/dist/shared/proto/enums/priority.d.ts.map +1 -0
  60. package/dist/shared/proto/enums/priority.js +4 -0
  61. package/dist/shared/proto/enums/reliability.d.ts.map +1 -0
  62. package/dist/shared/proto/index.d.ts +5 -0
  63. package/dist/shared/proto/index.d.ts.map +1 -0
  64. package/dist/{proto → shared/proto}/index.js +3 -3
  65. package/dist/shared/proto/offline/index.d.ts +7 -0
  66. package/dist/shared/proto/offline/index.d.ts.map +1 -0
  67. package/dist/shared/proto/offline/index.js +22 -0
  68. package/dist/shared/proto/offline/open-connection-reply-one.d.ts +9 -0
  69. package/dist/shared/proto/offline/open-connection-reply-one.d.ts.map +1 -0
  70. package/dist/shared/proto/offline/open-connection-reply-one.js +28 -0
  71. package/dist/shared/proto/offline/open-connection-reply-two.d.ts +11 -0
  72. package/dist/shared/proto/offline/open-connection-reply-two.d.ts.map +1 -0
  73. package/dist/shared/proto/offline/open-connection-reply-two.js +31 -0
  74. package/dist/shared/proto/offline/open-connection-request-one.d.ts +8 -0
  75. package/dist/shared/proto/offline/open-connection-request-one.d.ts.map +1 -0
  76. package/dist/shared/proto/offline/open-connection-request-one.js +25 -0
  77. package/dist/shared/proto/offline/open-connection-request-two.d.ts +10 -0
  78. package/dist/shared/proto/offline/open-connection-request-two.d.ts.map +1 -0
  79. package/dist/shared/proto/offline/open-connection-request-two.js +28 -0
  80. package/dist/shared/proto/offline/unconnected-ping.d.ts +8 -0
  81. package/dist/shared/proto/offline/unconnected-ping.d.ts.map +1 -0
  82. package/dist/shared/proto/offline/unconnected-ping.js +25 -0
  83. package/dist/shared/proto/offline/unconnected-pong.d.ts +9 -0
  84. package/dist/shared/proto/offline/unconnected-pong.d.ts.map +1 -0
  85. package/dist/shared/proto/offline/unconnected-pong.js +28 -0
  86. package/dist/shared/proto/online/ack.d.ts +7 -0
  87. package/dist/shared/proto/online/ack.d.ts.map +1 -0
  88. package/dist/{proto/packets → shared/proto/online}/ack.js +16 -31
  89. package/dist/shared/proto/online/connected-ping.d.ts +7 -0
  90. package/dist/shared/proto/online/connected-ping.d.ts.map +1 -0
  91. package/dist/shared/proto/online/connected-ping.js +19 -0
  92. package/dist/shared/proto/online/connected-pong.d.ts +8 -0
  93. package/dist/shared/proto/online/connected-pong.d.ts.map +1 -0
  94. package/dist/shared/proto/online/connected-pong.js +22 -0
  95. package/dist/shared/proto/online/connection-request-accepted.d.ts +12 -0
  96. package/dist/shared/proto/online/connection-request-accepted.d.ts.map +1 -0
  97. package/dist/shared/proto/online/connection-request-accepted.js +37 -0
  98. package/dist/shared/proto/online/connection-request.d.ts +9 -0
  99. package/dist/shared/proto/online/connection-request.d.ts.map +1 -0
  100. package/dist/shared/proto/online/connection-request.js +25 -0
  101. package/dist/shared/proto/online/disconnect-message.d.ts +6 -0
  102. package/dist/shared/proto/online/disconnect-message.d.ts.map +1 -0
  103. package/dist/shared/proto/online/disconnect-message.js +15 -0
  104. package/dist/shared/proto/online/frame-set.d.ts +9 -0
  105. package/dist/shared/proto/online/frame-set.d.ts.map +1 -0
  106. package/dist/shared/proto/online/frame-set.js +23 -0
  107. package/dist/shared/proto/online/index.d.ts +9 -0
  108. package/dist/shared/proto/online/index.d.ts.map +1 -0
  109. package/dist/shared/proto/online/index.js +24 -0
  110. package/dist/shared/proto/online/new-incomming-connection.d.ts +11 -0
  111. package/dist/shared/proto/online/new-incomming-connection.d.ts.map +1 -0
  112. package/dist/shared/proto/online/new-incomming-connection.js +33 -0
  113. package/dist/shared/proto/types/address.d.ts +12 -0
  114. package/dist/shared/proto/types/address.d.ts.map +1 -0
  115. package/dist/shared/proto/types/address.js +61 -0
  116. package/dist/shared/proto/types/frame.d.ts +23 -0
  117. package/dist/shared/proto/types/frame.d.ts.map +1 -0
  118. package/dist/shared/proto/types/frame.js +119 -0
  119. package/dist/{proto/packets → shared/proto}/types/index.d.ts +0 -2
  120. package/dist/shared/proto/types/index.d.ts.map +1 -0
  121. package/dist/{proto/packets → shared/proto}/types/index.js +0 -2
  122. package/dist/shared/proto/types/magic.d.ts +7 -0
  123. package/dist/shared/proto/types/magic.d.ts.map +1 -0
  124. package/dist/shared/proto/types/magic.js +15 -0
  125. package/dist/shared/proto/types/mtu.d.ts +7 -0
  126. package/dist/shared/proto/types/mtu.d.ts.map +1 -0
  127. package/dist/shared/proto/types/mtu.js +13 -0
  128. package/dist/tests/client-connect.d.ts +2 -0
  129. package/dist/tests/client-connect.d.ts.map +1 -0
  130. package/dist/tests/client-connect.js +32 -0
  131. package/dist/tests/client-once.d.ts +2 -0
  132. package/dist/tests/client-once.d.ts.map +1 -0
  133. package/dist/tests/client-once.js +11 -0
  134. package/dist/tests/server-listen.d.ts +2 -0
  135. package/dist/tests/server-listen.d.ts.map +1 -0
  136. package/dist/tests/server-listen.js +5 -0
  137. package/package.json +12 -6
  138. package/bun.lock +0 -67
  139. package/dist/client/framer.d.ts +0 -55
  140. package/dist/client/framer.d.ts.map +0 -1
  141. package/dist/client/framer.js +0 -458
  142. package/dist/proto/decorators/create.d.ts +0 -8
  143. package/dist/proto/decorators/create.d.ts.map +0 -1
  144. package/dist/proto/decorators/create.js +0 -77
  145. package/dist/proto/decorators/index.d.ts +0 -3
  146. package/dist/proto/decorators/index.d.ts.map +0 -1
  147. package/dist/proto/decorators/serialize.d.ts +0 -4
  148. package/dist/proto/decorators/serialize.d.ts.map +0 -1
  149. package/dist/proto/decorators/serialize.js +0 -12
  150. package/dist/proto/enums/flags.d.ts +0 -7
  151. package/dist/proto/enums/flags.d.ts.map +0 -1
  152. package/dist/proto/enums/flags.js +0 -10
  153. package/dist/proto/enums/index.d.ts +0 -6
  154. package/dist/proto/enums/index.d.ts.map +0 -1
  155. package/dist/proto/enums/packet.d.ts +0 -122
  156. package/dist/proto/enums/packet.d.ts.map +0 -1
  157. package/dist/proto/enums/packet.js +0 -125
  158. package/dist/proto/enums/priority.d.ts +0 -5
  159. package/dist/proto/enums/priority.d.ts.map +0 -1
  160. package/dist/proto/enums/priority.js +0 -8
  161. package/dist/proto/enums/reliability.d.ts.map +0 -1
  162. package/dist/proto/enums/status.d.ts +0 -7
  163. package/dist/proto/enums/status.d.ts.map +0 -1
  164. package/dist/proto/enums/status.js +0 -10
  165. package/dist/proto/index.d.ts +0 -5
  166. package/dist/proto/index.d.ts.map +0 -1
  167. package/dist/proto/packets/ack.d.ts +0 -10
  168. package/dist/proto/packets/ack.d.ts.map +0 -1
  169. package/dist/proto/packets/base-packet.d.ts +0 -26
  170. package/dist/proto/packets/base-packet.d.ts.map +0 -1
  171. package/dist/proto/packets/base-packet.js +0 -37
  172. package/dist/proto/packets/connected-ping.d.ts +0 -5
  173. package/dist/proto/packets/connected-ping.d.ts.map +0 -1
  174. package/dist/proto/packets/connected-ping.js +0 -27
  175. package/dist/proto/packets/connected-pong.d.ts +0 -6
  176. package/dist/proto/packets/connected-pong.d.ts.map +0 -1
  177. package/dist/proto/packets/connected-pong.js +0 -32
  178. package/dist/proto/packets/connection-request-accepted.d.ts +0 -10
  179. package/dist/proto/packets/connection-request-accepted.d.ts.map +0 -1
  180. package/dist/proto/packets/connection-request-accepted.js +0 -48
  181. package/dist/proto/packets/connection-request.d.ts +0 -7
  182. package/dist/proto/packets/connection-request.d.ts.map +0 -1
  183. package/dist/proto/packets/connection-request.js +0 -37
  184. package/dist/proto/packets/disconnect.d.ts +0 -5
  185. package/dist/proto/packets/disconnect.d.ts.map +0 -1
  186. package/dist/proto/packets/disconnect.js +0 -17
  187. package/dist/proto/packets/frame.d.ts +0 -1
  188. package/dist/proto/packets/frame.d.ts.map +0 -1
  189. package/dist/proto/packets/frame.js +0 -1
  190. package/dist/proto/packets/frameset.d.ts +0 -11
  191. package/dist/proto/packets/frameset.d.ts.map +0 -1
  192. package/dist/proto/packets/frameset.js +0 -37
  193. package/dist/proto/packets/incompatible-protocol-version.d.ts +0 -8
  194. package/dist/proto/packets/incompatible-protocol-version.d.ts.map +0 -1
  195. package/dist/proto/packets/incompatible-protocol-version.js +0 -38
  196. package/dist/proto/packets/index.d.ts +0 -19
  197. package/dist/proto/packets/index.d.ts.map +0 -1
  198. package/dist/proto/packets/index.js +0 -34
  199. package/dist/proto/packets/nack.d.ts +0 -8
  200. package/dist/proto/packets/nack.d.ts.map +0 -1
  201. package/dist/proto/packets/nack.js +0 -88
  202. package/dist/proto/packets/new-incoming-connection.d.ts +0 -9
  203. package/dist/proto/packets/new-incoming-connection.d.ts.map +0 -1
  204. package/dist/proto/packets/new-incoming-connection.js +0 -43
  205. package/dist/proto/packets/open-connection-reply-one.d.ts +0 -8
  206. package/dist/proto/packets/open-connection-reply-one.d.ts.map +0 -1
  207. package/dist/proto/packets/open-connection-reply-one.js +0 -43
  208. package/dist/proto/packets/open-connection-reply-two.d.ts +0 -10
  209. package/dist/proto/packets/open-connection-reply-two.d.ts.map +0 -1
  210. package/dist/proto/packets/open-connection-reply-two.js +0 -48
  211. package/dist/proto/packets/open-connection-request-one.d.ts +0 -7
  212. package/dist/proto/packets/open-connection-request-one.d.ts.map +0 -1
  213. package/dist/proto/packets/open-connection-request-one.js +0 -38
  214. package/dist/proto/packets/open-connection-request-two.d.ts +0 -9
  215. package/dist/proto/packets/open-connection-request-two.d.ts.map +0 -1
  216. package/dist/proto/packets/open-connection-request-two.js +0 -43
  217. package/dist/proto/packets/types/address.d.ts +0 -48
  218. package/dist/proto/packets/types/address.d.ts.map +0 -1
  219. package/dist/proto/packets/types/address.js +0 -99
  220. package/dist/proto/packets/types/data-type.d.ts +0 -21
  221. package/dist/proto/packets/types/data-type.d.ts.map +0 -1
  222. package/dist/proto/packets/types/data-type.js +0 -29
  223. package/dist/proto/packets/types/frame.d.ts +0 -23
  224. package/dist/proto/packets/types/frame.d.ts.map +0 -1
  225. package/dist/proto/packets/types/frame.js +0 -94
  226. package/dist/proto/packets/types/index.d.ts.map +0 -1
  227. package/dist/proto/packets/types/magic.d.ts +0 -7
  228. package/dist/proto/packets/types/magic.d.ts.map +0 -1
  229. package/dist/proto/packets/types/magic.js +0 -14
  230. package/dist/proto/packets/types/mtu.d.ts +0 -9
  231. package/dist/proto/packets/types/mtu.d.ts.map +0 -1
  232. package/dist/proto/packets/types/mtu.js +0 -18
  233. package/dist/proto/packets/types/sys-address.d.ts +0 -11
  234. package/dist/proto/packets/types/sys-address.d.ts.map +0 -1
  235. package/dist/proto/packets/types/sys-address.js +0 -32
  236. package/dist/proto/packets/unconnected-ping.d.ts +0 -7
  237. package/dist/proto/packets/unconnected-ping.d.ts.map +0 -1
  238. package/dist/proto/packets/unconnected-ping.js +0 -38
  239. package/dist/proto/packets/unconnected-pong.d.ts +0 -8
  240. package/dist/proto/packets/unconnected-pong.d.ts.map +0 -1
  241. package/dist/proto/packets/unconnected-pong.js +0 -43
  242. package/dist/proto/types/advertisement.d.ts.map +0 -1
  243. package/dist/proto/types/index.d.ts +0 -3
  244. package/dist/proto/types/index.d.ts.map +0 -1
  245. package/dist/proto/types/valid.d.ts +0 -4
  246. package/dist/proto/types/valid.d.ts.map +0 -1
  247. package/dist/server/server-events.d.ts +0 -9
  248. package/dist/server/server-events.d.ts.map +0 -1
  249. package/dist/server/server-options.d.ts +0 -26
  250. package/dist/server/server-options.d.ts.map +0 -1
  251. package/dist/server/server-options.js +0 -20
  252. package/dist/tests/client.d.ts +0 -2
  253. package/dist/tests/client.d.ts.map +0 -1
  254. package/dist/tests/client.js +0 -15
  255. package/dist/tests/localhost.d.ts +0 -2
  256. package/dist/tests/localhost.d.ts.map +0 -1
  257. package/dist/tests/localhost.js +0 -34
  258. package/dist/tests/server.d.ts +0 -2
  259. package/dist/tests/server.d.ts.map +0 -1
  260. package/dist/tests/server.js +0 -32
  261. package/dist/tests/test.d.ts +0 -2
  262. package/dist/tests/test.d.ts.map +0 -1
  263. package/dist/tests/test.js +0 -49
  264. package/dist/utils/Logger.d.ts.map +0 -1
  265. package/dist/utils/decorators.d.ts +0 -2
  266. package/dist/utils/decorators.d.ts.map +0 -1
  267. package/dist/utils/decorators.js +0 -17
  268. package/dist/utils/index.d.ts +0 -3
  269. package/dist/utils/index.d.ts.map +0 -1
  270. package/dist/utils/index.js +0 -18
  271. package/tsconfig.single.json +0 -9
  272. /package/dist/{proto/types/valid.js → server/types/connection-events.js} +0 -0
  273. /package/dist/server/{server-events.js → types/server-events.js} +0 -0
  274. /package/dist/{utils/Logger.js → shared/logger.js} +0 -0
  275. /package/dist/{proto → shared/proto}/enums/reliability.d.ts +0 -0
  276. /package/dist/{proto → shared/proto}/enums/reliability.js +0 -0
@@ -0,0 +1,247 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NetworkSession = void 0;
4
+ const binarystream_1 = require("@serenityjs/binarystream");
5
+ const proto_1 = require("./proto");
6
+ const logger_1 = require("./logger");
7
+ const MTU_HEADER_SIZE = 36;
8
+ class NetworkSession {
9
+ mtu;
10
+ send;
11
+ handle;
12
+ // Output
13
+ outputReliableIndex = 0;
14
+ outputSplitIndex = 0;
15
+ outputSequence = 0;
16
+ outputSequenceIndex;
17
+ outputOrderIndex;
18
+ outputFrames = new Set();
19
+ outputBackup = new Map();
20
+ // Input
21
+ receivedFrameSequences = new Set();
22
+ lostFrameSequences = new Set();
23
+ lastInputSequence = -1;
24
+ fragmentsQueue = new Map();
25
+ inputHighestSequenceIndex;
26
+ inputOrderIndex;
27
+ inputOrderingQueue = new Map();
28
+ constructor(mtu) {
29
+ this.mtu = mtu;
30
+ this.outputOrderIndex = new Array(32).fill(0);
31
+ this.outputSequenceIndex = new Array(32).fill(0);
32
+ this.inputHighestSequenceIndex = Array.from({ length: 32 }).fill(0);
33
+ this.inputOrderIndex = Array.from({ length: 32 }).fill(0);
34
+ for (let index = 0; index < 32; index++)
35
+ this.inputOrderingQueue.set(index, new Map());
36
+ }
37
+ onTick(tick) {
38
+ if (this.receivedFrameSequences.size > 0) {
39
+ const ackSeqs = Array.from(this.receivedFrameSequences);
40
+ this.receivedFrameSequences.clear();
41
+ const ack = new proto_1.Ack();
42
+ ack.sequences = ackSeqs;
43
+ this.send(ack.serialize());
44
+ }
45
+ if (this.lostFrameSequences.size > 0) {
46
+ const nackSeqs = Array.from(this.lostFrameSequences);
47
+ this.lostFrameSequences.clear();
48
+ const nack = new proto_1.Ack();
49
+ nack.sequences = nackSeqs;
50
+ const payload = nack.serialize();
51
+ payload[0] = proto_1.Packets.Nack;
52
+ this.send(payload);
53
+ }
54
+ const size = this.outputFrames.size;
55
+ if (size > 0)
56
+ this.sendQueue(size);
57
+ }
58
+ onAck(ack) {
59
+ for (let i = 0, len = ack.sequences.length; i < len; i++) {
60
+ this.outputBackup.delete(ack.sequences[i]);
61
+ }
62
+ }
63
+ onNack(nack) {
64
+ for (let i = 0, len = nack.sequences.length; i < len; i++) {
65
+ const seq = nack.sequences[i];
66
+ const lostFrames = this.outputBackup.get(seq) || [];
67
+ for (let j = 0, lostLen = lostFrames.length; j < lostLen; j++) {
68
+ this.sendFrame(lostFrames[j], proto_1.Priority.High);
69
+ }
70
+ }
71
+ }
72
+ frameAndSend(data, priority = proto_1.Priority.Medium) {
73
+ const frame = new proto_1.Frame();
74
+ frame.orderChannel = 0;
75
+ frame.payload = data;
76
+ this.sendFrame(frame, priority);
77
+ }
78
+ sendFrame(frame, priority = proto_1.Priority.Medium) {
79
+ const channel = frame.orderChannel;
80
+ if (frame.isSequenced()) {
81
+ frame.orderedFrameIndex = this.outputOrderIndex[channel];
82
+ frame.sequenceFrameIndex = this.outputSequenceIndex[channel]++;
83
+ }
84
+ else if (frame.isOrdered()) {
85
+ frame.orderedFrameIndex = this.outputOrderIndex[channel]++;
86
+ this.outputSequenceIndex[channel] = 0;
87
+ }
88
+ const maxSize = this.mtu - MTU_HEADER_SIZE;
89
+ const payloadSize = frame.payload.byteLength;
90
+ if (payloadSize > maxSize) {
91
+ const splitSize = Math.ceil(payloadSize / maxSize);
92
+ const splitId = this.outputSplitIndex++ & 0xffff;
93
+ for (let i = 0; i < splitSize; i++) {
94
+ const index = i * maxSize;
95
+ const nF = new proto_1.Frame();
96
+ if (frame.isReliable()) {
97
+ nF.reliableFrameIndex = this.outputReliableIndex++;
98
+ }
99
+ nF.sequenceFrameIndex = frame.sequenceFrameIndex;
100
+ nF.orderedFrameIndex = frame.orderedFrameIndex;
101
+ nF.orderChannel = frame.orderChannel;
102
+ nF.reliability = frame.reliability;
103
+ nF.payload = frame.payload.subarray(index, Math.min(index + maxSize, payloadSize));
104
+ nF.splitFrameIndex = i;
105
+ nF.splitId = splitId;
106
+ nF.splitSize = splitSize;
107
+ this.queueFrame(nF, priority);
108
+ }
109
+ }
110
+ else {
111
+ if (frame.isReliable()) {
112
+ frame.reliableFrameIndex = this.outputReliableIndex++;
113
+ }
114
+ this.queueFrame(frame, priority);
115
+ }
116
+ }
117
+ queueFrame(frame, priority) {
118
+ let length = 4;
119
+ for (const frame of this.outputFrames)
120
+ length += frame.getByteLength();
121
+ if (length + frame.getByteLength() > this.mtu - MTU_HEADER_SIZE)
122
+ this.sendQueue(this.outputFrames.size);
123
+ this.outputFrames.add(frame);
124
+ if (priority === proto_1.Priority.High)
125
+ this.sendQueue(1);
126
+ }
127
+ sendQueue(amount) {
128
+ if (this.outputFrames.size === 0)
129
+ return;
130
+ const frameset = new proto_1.FrameSet();
131
+ frameset.sequence = this.outputSequence++;
132
+ frameset.frames = [...this.outputFrames].slice(0, amount);
133
+ this.outputBackup.set(frameset.sequence, frameset.frames);
134
+ for (const frame of frameset.frames)
135
+ this.outputFrames.delete(frame);
136
+ const buffer = frameset.serialize();
137
+ if (!this.send)
138
+ throw new Error("Send method was not initialized");
139
+ this.send(buffer);
140
+ }
141
+ onFrameSet(frameSet) {
142
+ if (this.receivedFrameSequences.has(frameSet.sequence)) {
143
+ throw new Error("Duplicate frame set received");
144
+ }
145
+ this.lostFrameSequences.delete(frameSet.sequence);
146
+ const isLess = frameSet.sequence < this.lastInputSequence;
147
+ const isEqual = frameSet.sequence === this.lastInputSequence;
148
+ if (isLess || isEqual) {
149
+ throw new Error("Frame set received is out of order");
150
+ }
151
+ this.receivedFrameSequences.add(frameSet.sequence);
152
+ const diff = frameSet.sequence - this.lastInputSequence;
153
+ if (diff > 1) {
154
+ for (let index = this.lastInputSequence + 1; index < frameSet.sequence; index++)
155
+ this.lostFrameSequences.add(index);
156
+ }
157
+ this.lastInputSequence = frameSet.sequence;
158
+ for (const frame of frameSet.frames) {
159
+ this.handleFrame(frame);
160
+ }
161
+ }
162
+ handleFrame(frame) {
163
+ if (frame.isSplit()) {
164
+ this.handleSplitFrame(frame);
165
+ }
166
+ else if (frame.isSequenced()) {
167
+ this.handleSequenced(frame);
168
+ }
169
+ else if (frame.isOrdered()) {
170
+ this.handleOrdered(frame);
171
+ }
172
+ else {
173
+ this.handle(frame.payload);
174
+ }
175
+ }
176
+ handleSplitFrame(frame) {
177
+ const splitId = frame.splitId;
178
+ let entry = this.fragmentsQueue.get(splitId);
179
+ if (!entry) {
180
+ entry = new Map();
181
+ this.fragmentsQueue.set(splitId, entry);
182
+ }
183
+ entry.set(frame.splitFrameIndex, frame);
184
+ if (entry.size === frame.splitSize) {
185
+ {
186
+ const stream = new binarystream_1.BinaryStream();
187
+ for (let index = 0; index < frame.splitSize; index++) {
188
+ const sframe = entry.get(index);
189
+ if (!sframe) {
190
+ throw new Error(`Missing fragment at index ${index} for splitId=${frame.splitId}`);
191
+ }
192
+ stream.write(sframe.payload);
193
+ }
194
+ const reassembledFrame = new proto_1.Frame();
195
+ reassembledFrame.reliability = frame.reliability;
196
+ reassembledFrame.reliableFrameIndex = frame.reliableFrameIndex;
197
+ reassembledFrame.sequenceFrameIndex = frame.sequenceFrameIndex;
198
+ reassembledFrame.orderedFrameIndex = frame.orderedFrameIndex;
199
+ reassembledFrame.orderChannel = frame.orderChannel;
200
+ reassembledFrame.payload = stream.getBuffer();
201
+ this.handleFrame(reassembledFrame);
202
+ }
203
+ this.fragmentsQueue.delete(splitId);
204
+ }
205
+ }
206
+ handleSequenced(frame) {
207
+ const channel = frame.orderChannel;
208
+ const currentHighestSequence = this.inputHighestSequenceIndex[channel];
209
+ const isLess = frame.sequenceFrameIndex < currentHighestSequence;
210
+ if (isLess || frame.orderedFrameIndex === this.inputOrderIndex[channel]) {
211
+ logger_1.Logger.warn("Frame dropped, sequence is less than current highest sequence");
212
+ return;
213
+ }
214
+ this.inputHighestSequenceIndex[channel] = frame.sequenceFrameIndex + 1;
215
+ this.handle(frame.payload);
216
+ }
217
+ handleOrdered(frame) {
218
+ const channel = frame.orderChannel;
219
+ const expectedOrderIndex = this.inputOrderIndex[channel];
220
+ const isEqual = frame.orderedFrameIndex === expectedOrderIndex;
221
+ if (frame.orderedFrameIndex > expectedOrderIndex) {
222
+ const unordered = this.inputOrderingQueue.get(channel);
223
+ if (!unordered) {
224
+ logger_1.Logger.warn("No unordered queue found");
225
+ return;
226
+ }
227
+ unordered.set(frame.orderedFrameIndex, frame);
228
+ }
229
+ else if (isEqual) {
230
+ this.inputHighestSequenceIndex[frame.orderChannel] = 0;
231
+ this.inputOrderIndex[frame.orderChannel] = frame.orderedFrameIndex + 1;
232
+ this.handle(frame.payload);
233
+ let index = this.inputOrderIndex[frame.orderChannel];
234
+ const outOfOrderQueue = this.inputOrderingQueue.get(frame.orderChannel);
235
+ for (; outOfOrderQueue.has(index); index++) {
236
+ const frame = outOfOrderQueue.get(index);
237
+ if (!frame)
238
+ break;
239
+ this.handle(frame.payload);
240
+ outOfOrderQueue.delete(index);
241
+ }
242
+ this.inputOrderingQueue.set(frame.orderChannel, outOfOrderQueue);
243
+ this.inputOrderIndex[frame.orderChannel] = index;
244
+ }
245
+ }
246
+ }
247
+ exports.NetworkSession = NetworkSession;
@@ -0,0 +1,8 @@
1
+ export declare enum ConnectionStatus {
2
+ Disconnected = 0,
3
+ Connecting = 1,
4
+ Connected = 2,
5
+ Disconnecting = 3,
6
+ Error = 4
7
+ }
8
+ //# sourceMappingURL=connectionStatus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connectionStatus.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/enums/connectionStatus.ts"],"names":[],"mappings":"AAAA,oBAAY,gBAAgB;IAC3B,YAAY,IAAI;IAChB,UAAU,IAAI;IACd,SAAS,IAAI;IACb,aAAa,IAAI;IACjB,KAAK,IAAI;CACT"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConnectionStatus = void 0;
4
+ var ConnectionStatus;
5
+ (function (ConnectionStatus) {
6
+ ConnectionStatus[ConnectionStatus["Disconnected"] = 0] = "Disconnected";
7
+ ConnectionStatus[ConnectionStatus["Connecting"] = 1] = "Connecting";
8
+ ConnectionStatus[ConnectionStatus["Connected"] = 2] = "Connected";
9
+ ConnectionStatus[ConnectionStatus["Disconnecting"] = 3] = "Disconnecting";
10
+ ConnectionStatus[ConnectionStatus["Error"] = 4] = "Error";
11
+ })(ConnectionStatus || (exports.ConnectionStatus = ConnectionStatus = {}));
@@ -0,0 +1,5 @@
1
+ export * from "./packets";
2
+ export * from "./connectionStatus";
3
+ export * from "./reliability";
4
+ export * from "./priority";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/enums/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
@@ -14,8 +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("./packet"), exports);
18
- __exportStar(require("./flags"), exports);
17
+ __exportStar(require("./packets"), exports);
18
+ __exportStar(require("./connectionStatus"), exports);
19
19
  __exportStar(require("./reliability"), exports);
20
20
  __exportStar(require("./priority"), exports);
21
- __exportStar(require("./status"), exports);
@@ -0,0 +1,19 @@
1
+ export declare enum Packets {
2
+ ConnectedPing = 0,// 0
3
+ UnconnectedPing = 1,// 1
4
+ ConnectedPong = 3,// 3
5
+ OpenConnectionRequest1 = 5,// 5
6
+ OpenConnectionReply1 = 6,// 6
7
+ OpenConnectionRequest2 = 7,// 7
8
+ OpenConnectionReply2 = 8,// 8
9
+ ConnectionRequest = 9,// 9
10
+ ConnectionRequestAccepted = 16,// 16
11
+ NewIncomingConnection = 19,// 19
12
+ Disconnect = 21,// 21
13
+ IncompatibleProtocolVersion = 25,// 25
14
+ UnconnectedPong = 28,// 28
15
+ FrameSet = 128,// 128
16
+ Nack = 160,// 160
17
+ Ack = 192
18
+ }
19
+ //# sourceMappingURL=packets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packets.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/enums/packets.ts"],"names":[],"mappings":"AACA,oBAAY,OAAO;IAClB,aAAa,IAAO,CAAE,IAAI;IAC1B,eAAe,IAAO,CAAE,IAAI;IAC5B,aAAa,IAAO,CAAE,IAAI;IAC1B,sBAAsB,IAAO,CAAE,IAAI;IACnC,oBAAoB,IAAO,CAAE,IAAI;IACjC,sBAAsB,IAAO,CAAE,IAAI;IACnC,oBAAoB,IAAO,CAAE,IAAI;IACjC,iBAAiB,IAAO,CAAE,IAAI;IAC9B,yBAAyB,KAAO,CAAE,KAAK;IACvC,qBAAqB,KAAO,CAAE,KAAK;IACnC,UAAU,KAAO,CAAE,KAAK;IACxB,2BAA2B,KAAO,CAAE,KAAK;IACzC,eAAe,KAAO,CAAE,KAAK;IAC7B,QAAQ,MAAO,CAAE,MAAM;IACvB,IAAI,MAAO,CAAE,MAAM;IACnB,GAAG,MAAO;CACV"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Packets = void 0;
4
+ // Only used packets are listed.
5
+ var Packets;
6
+ (function (Packets) {
7
+ Packets[Packets["ConnectedPing"] = 0] = "ConnectedPing";
8
+ Packets[Packets["UnconnectedPing"] = 1] = "UnconnectedPing";
9
+ Packets[Packets["ConnectedPong"] = 3] = "ConnectedPong";
10
+ Packets[Packets["OpenConnectionRequest1"] = 5] = "OpenConnectionRequest1";
11
+ Packets[Packets["OpenConnectionReply1"] = 6] = "OpenConnectionReply1";
12
+ Packets[Packets["OpenConnectionRequest2"] = 7] = "OpenConnectionRequest2";
13
+ Packets[Packets["OpenConnectionReply2"] = 8] = "OpenConnectionReply2";
14
+ Packets[Packets["ConnectionRequest"] = 9] = "ConnectionRequest";
15
+ Packets[Packets["ConnectionRequestAccepted"] = 16] = "ConnectionRequestAccepted";
16
+ Packets[Packets["NewIncomingConnection"] = 19] = "NewIncomingConnection";
17
+ Packets[Packets["Disconnect"] = 21] = "Disconnect";
18
+ Packets[Packets["IncompatibleProtocolVersion"] = 25] = "IncompatibleProtocolVersion";
19
+ Packets[Packets["UnconnectedPong"] = 28] = "UnconnectedPong";
20
+ Packets[Packets["FrameSet"] = 128] = "FrameSet";
21
+ Packets[Packets["Nack"] = 160] = "Nack";
22
+ Packets[Packets["Ack"] = 192] = "Ack";
23
+ })(Packets || (exports.Packets = Packets = {}));
@@ -0,0 +1,6 @@
1
+ export declare const Priority: {
2
+ readonly Medium: 0;
3
+ readonly High: 1;
4
+ };
5
+ export type Priority = (typeof Priority)[keyof typeof Priority];
6
+ //# sourceMappingURL=priority.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priority.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/enums/priority.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;CAAkC,CAAC;AACxD,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Priority = void 0;
4
+ exports.Priority = { Medium: 0, High: 1 };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reliability.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/enums/reliability.ts"],"names":[],"mappings":"AAAA,oBAAY,WAAW;IACtB,UAAU,IAAI;IACd,mBAAmB,IAAI;IACvB,QAAQ,IAAI;IACZ,eAAe,IAAI;IACnB,iBAAiB,IAAI;IACrB,wBAAwB,IAAI;IAC5B,sBAAsB,IAAI;IAC1B,6BAA6B,IAAI;CACjC"}
@@ -0,0 +1,5 @@
1
+ export * from "./enums";
2
+ export * from "./offline";
3
+ export * from "./types";
4
+ export * from "./online";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/proto/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
@@ -14,7 +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("./decorators"), exports);
18
- __exportStar(require("./packets"), exports);
19
- __exportStar(require("./types"), exports);
20
17
  __exportStar(require("./enums"), exports);
18
+ __exportStar(require("./offline"), exports);
19
+ __exportStar(require("./types"), exports);
20
+ __exportStar(require("./online"), exports);
@@ -0,0 +1,7 @@
1
+ export * from "./unconnected-ping";
2
+ export * from "./unconnected-pong";
3
+ export * from "./open-connection-request-one";
4
+ export * from "./open-connection-reply-one";
5
+ export * from "./open-connection-request-two";
6
+ export * from "./open-connection-reply-two";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/offline/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./unconnected-ping"), exports);
18
+ __exportStar(require("./unconnected-pong"), exports);
19
+ __exportStar(require("./open-connection-request-one"), exports);
20
+ __exportStar(require("./open-connection-reply-one"), exports);
21
+ __exportStar(require("./open-connection-request-two"), exports);
22
+ __exportStar(require("./open-connection-reply-two"), exports);
@@ -0,0 +1,9 @@
1
+ import { BinaryStream } from "@serenityjs/binarystream";
2
+ export declare class OpenConnectionReplyOne extends BinaryStream {
3
+ guid: bigint;
4
+ security: boolean;
5
+ mtu: number;
6
+ serialize(): Buffer;
7
+ deserialize(): OpenConnectionReplyOne;
8
+ }
9
+ //# sourceMappingURL=open-connection-reply-one.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-connection-reply-one.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/offline/open-connection-reply-one.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EAKZ,MAAM,0BAA0B,CAAC;AAIlC,qBAAa,sBAAuB,SAAQ,YAAY;IAChD,IAAI,EAAG,MAAM,CAAC;IACd,QAAQ,EAAG,OAAO,CAAC;IACnB,GAAG,EAAG,MAAM,CAAC;IAEb,SAAS,IAAI,MAAM;IASnB,WAAW,IAAI,sBAAsB;CAQ5C"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenConnectionReplyOne = void 0;
4
+ const binarystream_1 = require("@serenityjs/binarystream");
5
+ const enums_1 = require("../enums");
6
+ const types_1 = require("../types");
7
+ class OpenConnectionReplyOne extends binarystream_1.BinaryStream {
8
+ guid;
9
+ security;
10
+ mtu;
11
+ serialize() {
12
+ binarystream_1.Uint8.write(this, enums_1.Packets.OpenConnectionReply1);
13
+ types_1.Magic.write(this);
14
+ binarystream_1.Int64.write(this, this.guid);
15
+ binarystream_1.Bool.write(this, this.security);
16
+ binarystream_1.Int16.write(this, this.mtu);
17
+ return this.getBuffer();
18
+ }
19
+ deserialize() {
20
+ binarystream_1.Uint8.read(this);
21
+ types_1.Magic.read(this);
22
+ this.guid = binarystream_1.Int64.read(this);
23
+ this.security = binarystream_1.Bool.read(this);
24
+ this.mtu = binarystream_1.Int16.read(this);
25
+ return this;
26
+ }
27
+ }
28
+ exports.OpenConnectionReplyOne = OpenConnectionReplyOne;
@@ -0,0 +1,11 @@
1
+ import { BinaryStream } from "@serenityjs/binarystream";
2
+ import { Address } from "../types";
3
+ export declare class OpenConnectionReplyTwo extends BinaryStream {
4
+ guid: bigint;
5
+ address: Address;
6
+ mtu: number;
7
+ encryptionEnabled: boolean;
8
+ serialize(): Buffer;
9
+ deserialize(): OpenConnectionReplyTwo;
10
+ }
11
+ //# sourceMappingURL=open-connection-reply-two.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-connection-reply-two.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/offline/open-connection-reply-two.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EAKZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAAS,MAAM,UAAU,CAAC;AAG1C,qBAAa,sBAAuB,SAAQ,YAAY;IAChD,IAAI,EAAG,MAAM,CAAC;IACd,OAAO,EAAG,OAAO,CAAC;IAClB,GAAG,EAAG,MAAM,CAAC;IACb,iBAAiB,EAAG,OAAO,CAAC;IAE5B,SAAS,IAAI,MAAM;IAUnB,WAAW,IAAI,sBAAsB;CAS5C"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenConnectionReplyTwo = void 0;
4
+ const binarystream_1 = require("@serenityjs/binarystream");
5
+ const types_1 = require("../types");
6
+ const enums_1 = require("../enums");
7
+ class OpenConnectionReplyTwo extends binarystream_1.BinaryStream {
8
+ guid;
9
+ address;
10
+ mtu;
11
+ encryptionEnabled;
12
+ serialize() {
13
+ binarystream_1.Uint8.write(this, enums_1.Packets.OpenConnectionReply2);
14
+ types_1.Magic.write(this);
15
+ binarystream_1.Int64.write(this, this.guid);
16
+ types_1.Address.write(this, this.address);
17
+ binarystream_1.Int16.write(this, this.mtu);
18
+ binarystream_1.Bool.write(this, this.encryptionEnabled);
19
+ return this.getBuffer();
20
+ }
21
+ deserialize() {
22
+ binarystream_1.Uint8.read(this);
23
+ types_1.Magic.read(this);
24
+ this.guid = binarystream_1.Int64.read(this);
25
+ this.address = types_1.Address.read(this);
26
+ this.mtu = binarystream_1.Int16.read(this);
27
+ this.encryptionEnabled = binarystream_1.Bool.read(this);
28
+ return this;
29
+ }
30
+ }
31
+ exports.OpenConnectionReplyTwo = OpenConnectionReplyTwo;
@@ -0,0 +1,8 @@
1
+ import { BinaryStream } from "@serenityjs/binarystream";
2
+ export declare class OpenConnectionRequestOne extends BinaryStream {
3
+ protocol: number;
4
+ mtu: number;
5
+ serialize(): Buffer;
6
+ deserialize(): OpenConnectionRequestOne;
7
+ }
8
+ //# sourceMappingURL=open-connection-request-one.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-connection-request-one.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/offline/open-connection-request-one.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAS,MAAM,0BAA0B,CAAC;AAI/D,qBAAa,wBAAyB,SAAQ,YAAY;IAClD,QAAQ,EAAG,MAAM,CAAC;IAClB,GAAG,EAAG,MAAM,CAAC;IAEb,SAAS,IAAI,MAAM;IAQnB,WAAW,IAAI,wBAAwB;CAO9C"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenConnectionRequestOne = void 0;
4
+ const binarystream_1 = require("@serenityjs/binarystream");
5
+ const enums_1 = require("../enums");
6
+ const types_1 = require("../types");
7
+ class OpenConnectionRequestOne extends binarystream_1.BinaryStream {
8
+ protocol;
9
+ mtu;
10
+ serialize() {
11
+ binarystream_1.Uint8.write(this, enums_1.Packets.OpenConnectionRequest1);
12
+ types_1.Magic.write(this);
13
+ binarystream_1.Uint8.write(this, this.protocol);
14
+ types_1.MTU.write(this, this.mtu);
15
+ return this.getBuffer();
16
+ }
17
+ deserialize() {
18
+ binarystream_1.Uint8.read(this);
19
+ types_1.Magic.read(this);
20
+ this.protocol = binarystream_1.Uint8.read(this);
21
+ this.mtu = types_1.MTU.read(this);
22
+ return this;
23
+ }
24
+ }
25
+ exports.OpenConnectionRequestOne = OpenConnectionRequestOne;
@@ -0,0 +1,10 @@
1
+ import { BinaryStream } from "@serenityjs/binarystream";
2
+ import { Address } from "../types";
3
+ export declare class OpenConnectionRequestTwo extends BinaryStream {
4
+ address: Address;
5
+ mtu: number;
6
+ guid: bigint;
7
+ serialize(): Buffer;
8
+ deserialize(): OpenConnectionRequestTwo;
9
+ }
10
+ //# sourceMappingURL=open-connection-request-two.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"open-connection-request-two.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/offline/open-connection-request-two.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,0BAA0B,CAAC;AAE7E,OAAO,EAAE,OAAO,EAAS,MAAM,UAAU,CAAC;AAE1C,qBAAa,wBAAyB,SAAQ,YAAY;IAClD,OAAO,EAAG,OAAO,CAAC;IAClB,GAAG,EAAG,MAAM,CAAC;IACb,IAAI,EAAG,MAAM,CAAC;IAEd,SAAS,IAAI,MAAM;IASnB,WAAW,IAAI,wBAAwB;CAQ9C"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpenConnectionRequestTwo = void 0;
4
+ const binarystream_1 = require("@serenityjs/binarystream");
5
+ const enums_1 = require("../enums");
6
+ const types_1 = require("../types");
7
+ class OpenConnectionRequestTwo extends binarystream_1.BinaryStream {
8
+ address;
9
+ mtu;
10
+ guid;
11
+ serialize() {
12
+ binarystream_1.Uint8.write(this, enums_1.Packets.OpenConnectionRequest2);
13
+ types_1.Magic.write(this);
14
+ types_1.Address.write(this, this.address);
15
+ binarystream_1.Int16.write(this, this.mtu);
16
+ binarystream_1.Int64.write(this, this.guid);
17
+ return this.getBuffer();
18
+ }
19
+ deserialize() {
20
+ binarystream_1.Uint8.read(this);
21
+ types_1.Magic.read(this);
22
+ this.address = types_1.Address.read(this);
23
+ this.mtu = binarystream_1.Int16.read(this);
24
+ this.guid = binarystream_1.Int64.read(this);
25
+ return this;
26
+ }
27
+ }
28
+ exports.OpenConnectionRequestTwo = OpenConnectionRequestTwo;
@@ -0,0 +1,8 @@
1
+ import { BinaryStream } from "@serenityjs/binarystream";
2
+ export declare class UnconnectedPing extends BinaryStream {
3
+ timestamp: bigint;
4
+ guid: bigint;
5
+ serialize(): Buffer;
6
+ deserialize(): UnconnectedPing;
7
+ }
8
+ //# sourceMappingURL=unconnected-ping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unconnected-ping.d.ts","sourceRoot":"","sources":["../../../../src/shared/proto/offline/unconnected-ping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,0BAA0B,CAAC;AAItE,qBAAa,eAAgB,SAAQ,YAAY;IACzC,SAAS,EAAG,MAAM,CAAC;IACnB,IAAI,EAAG,MAAM,CAAC;IAEd,SAAS,IAAI,MAAM;IAQnB,WAAW,IAAI,eAAe;CAOrC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnconnectedPing = void 0;
4
+ const binarystream_1 = require("@serenityjs/binarystream");
5
+ const enums_1 = require("../enums");
6
+ const types_1 = require("../types");
7
+ class UnconnectedPing extends binarystream_1.BinaryStream {
8
+ timestamp; // Int64
9
+ guid; // Int64
10
+ serialize() {
11
+ binarystream_1.Uint8.write(this, enums_1.Packets.UnconnectedPing);
12
+ binarystream_1.Int64.write(this, this.timestamp);
13
+ types_1.Magic.write(this);
14
+ binarystream_1.Int64.write(this, this.guid);
15
+ return this.getBuffer();
16
+ }
17
+ deserialize() {
18
+ binarystream_1.Uint8.read(this);
19
+ this.timestamp = binarystream_1.Int64.read(this);
20
+ types_1.Magic.read(this);
21
+ this.guid = binarystream_1.Int64.read(this);
22
+ return this;
23
+ }
24
+ }
25
+ exports.UnconnectedPing = UnconnectedPing;