@dcl/ecs 7.7.1 → 7.7.2-12951019665.commit-c8695cd
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.
|
@@ -206,14 +206,22 @@ export function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
206
206
|
// Send CRDT messages to transports
|
|
207
207
|
const transportBuffer = new ReadWriteByteBuffer();
|
|
208
208
|
for (const index in transports) {
|
|
209
|
+
// NetworkMessages can only have a MAX_SIZE of 13kb. So we need to send it in chunks.
|
|
210
|
+
const LIVEKIT_MAX_SIZE = 13;
|
|
211
|
+
const __NetworkMessagesBuffer = [];
|
|
209
212
|
const transportIndex = Number(index);
|
|
210
213
|
const transport = transports[transportIndex];
|
|
211
214
|
const isRendererTransport = transport.type === 'renderer';
|
|
212
215
|
const isNetworkTransport = transport.type === 'network';
|
|
216
|
+
// Reset Buffer for each Transport
|
|
213
217
|
transportBuffer.resetBuffer();
|
|
214
218
|
const buffer = new ReadWriteByteBuffer();
|
|
215
219
|
// Then we send all the new crdtMessages that the transport needs to process
|
|
216
220
|
for (const message of crdtMessages) {
|
|
221
|
+
if (isNetworkTransport && transportBuffer.toBinary().byteLength / 1024 > LIVEKIT_MAX_SIZE) {
|
|
222
|
+
__NetworkMessagesBuffer.push(transportBuffer.toBinary());
|
|
223
|
+
transportBuffer.resetBuffer();
|
|
224
|
+
}
|
|
217
225
|
// Avoid echo messages
|
|
218
226
|
if (message.transportId === transportIndex)
|
|
219
227
|
continue;
|
|
@@ -261,7 +269,10 @@ export function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
261
269
|
// Common message
|
|
262
270
|
transportBuffer.writeBuffer(message.messageBuffer, false);
|
|
263
271
|
}
|
|
264
|
-
|
|
272
|
+
if (isNetworkTransport && transportBuffer.currentWriteOffset()) {
|
|
273
|
+
__NetworkMessagesBuffer.push(transportBuffer.toBinary());
|
|
274
|
+
}
|
|
275
|
+
const message = isNetworkTransport ? __NetworkMessagesBuffer : transportBuffer.toBinary();
|
|
265
276
|
await transport.send(message);
|
|
266
277
|
}
|
|
267
278
|
}
|
|
@@ -21,7 +21,11 @@ export type TransportMessage = Omit<ReceiveMessage, 'data'>;
|
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
23
|
export type Transport = {
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* For Network messages its an Uint8Array[]. Due too the LiveKit MAX_SIZE = 13kb
|
|
26
|
+
* For Renderer & Other transports we send a single Uint8Array
|
|
27
|
+
*/
|
|
28
|
+
send(message: Uint8Array | Uint8Array[]): Promise<void>;
|
|
25
29
|
onmessage?(message: Uint8Array): void;
|
|
26
30
|
filter(message: Omit<TransportMessage, 'messageBuffer'>): boolean;
|
|
27
31
|
type?: string;
|
|
@@ -232,14 +232,22 @@ function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
232
232
|
// Send CRDT messages to transports
|
|
233
233
|
const transportBuffer = new ByteBuffer_1.ReadWriteByteBuffer();
|
|
234
234
|
for (const index in transports) {
|
|
235
|
+
// NetworkMessages can only have a MAX_SIZE of 13kb. So we need to send it in chunks.
|
|
236
|
+
const LIVEKIT_MAX_SIZE = 13;
|
|
237
|
+
const __NetworkMessagesBuffer = [];
|
|
235
238
|
const transportIndex = Number(index);
|
|
236
239
|
const transport = transports[transportIndex];
|
|
237
240
|
const isRendererTransport = transport.type === 'renderer';
|
|
238
241
|
const isNetworkTransport = transport.type === 'network';
|
|
242
|
+
// Reset Buffer for each Transport
|
|
239
243
|
transportBuffer.resetBuffer();
|
|
240
244
|
const buffer = new ByteBuffer_1.ReadWriteByteBuffer();
|
|
241
245
|
// Then we send all the new crdtMessages that the transport needs to process
|
|
242
246
|
for (const message of crdtMessages) {
|
|
247
|
+
if (isNetworkTransport && transportBuffer.toBinary().byteLength / 1024 > LIVEKIT_MAX_SIZE) {
|
|
248
|
+
__NetworkMessagesBuffer.push(transportBuffer.toBinary());
|
|
249
|
+
transportBuffer.resetBuffer();
|
|
250
|
+
}
|
|
243
251
|
// Avoid echo messages
|
|
244
252
|
if (message.transportId === transportIndex)
|
|
245
253
|
continue;
|
|
@@ -287,7 +295,10 @@ function crdtSceneSystem(engine, onProcessEntityComponentChange) {
|
|
|
287
295
|
// Common message
|
|
288
296
|
transportBuffer.writeBuffer(message.messageBuffer, false);
|
|
289
297
|
}
|
|
290
|
-
|
|
298
|
+
if (isNetworkTransport && transportBuffer.currentWriteOffset()) {
|
|
299
|
+
__NetworkMessagesBuffer.push(transportBuffer.toBinary());
|
|
300
|
+
}
|
|
301
|
+
const message = isNetworkTransport ? __NetworkMessagesBuffer : transportBuffer.toBinary();
|
|
291
302
|
await transport.send(message);
|
|
292
303
|
}
|
|
293
304
|
}
|
|
@@ -21,7 +21,11 @@ export type TransportMessage = Omit<ReceiveMessage, 'data'>;
|
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
23
|
export type Transport = {
|
|
24
|
-
|
|
24
|
+
/**
|
|
25
|
+
* For Network messages its an Uint8Array[]. Due too the LiveKit MAX_SIZE = 13kb
|
|
26
|
+
* For Renderer & Other transports we send a single Uint8Array
|
|
27
|
+
*/
|
|
28
|
+
send(message: Uint8Array | Uint8Array[]): Promise<void>;
|
|
25
29
|
onmessage?(message: Uint8Array): void;
|
|
26
30
|
filter(message: Omit<TransportMessage, 'messageBuffer'>): boolean;
|
|
27
31
|
type?: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/ecs",
|
|
3
3
|
"description": "Decentraland ECS",
|
|
4
|
-
"version": "7.7.
|
|
4
|
+
"version": "7.7.2-12951019665.commit-c8695cd",
|
|
5
5
|
"author": "DCL",
|
|
6
6
|
"bugs": "https://github.com/decentraland/ecs/issues",
|
|
7
7
|
"files": [
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
},
|
|
34
34
|
"types": "./dist/index.d.ts",
|
|
35
35
|
"typings": "./dist/index.d.ts",
|
|
36
|
-
"commit": "
|
|
36
|
+
"commit": "c8695cd9b94e87ad567520089969583d9d36637f"
|
|
37
37
|
}
|