@dxos/messaging 0.1.56-main.c787da3 → 0.1.56-main.ccd5e3b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +374 -120
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +376 -122
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/messenger.d.ts.map +1 -1
- package/dist/types/src/signal-client/signal-client.d.ts.map +1 -1
- package/dist/types/src/signal-client/signal-rpc-client.d.ts.map +1 -1
- package/dist/types/src/signal-manager/memory-signal-manager.d.ts +3 -0
- package/dist/types/src/signal-manager/memory-signal-manager.d.ts.map +1 -1
- package/dist/types/src/signal-manager/websocket-signal-manager.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/messenger.test.ts +2 -3
- package/src/messenger.ts +1 -3
- package/src/signal-client/signal-client.ts +4 -5
- package/src/signal-client/signal-rpc-client.ts +1 -1
- package/src/signal-manager/memory-signal-manager.ts +53 -6
- package/src/signal-manager/websocket-signal-manager.ts +1 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
3
|
// packages/core/mesh/messaging/src/messenger.ts
|
|
4
|
-
import invariant from "tiny-invariant";
|
|
5
4
|
import { TimeoutError, scheduleExponentialBackoffTaskInterval, scheduleTask } from "@dxos/async";
|
|
6
5
|
import { Context } from "@dxos/context";
|
|
6
|
+
import { invariant } from "@dxos/invariant";
|
|
7
7
|
import { PublicKey } from "@dxos/keys";
|
|
8
8
|
import { log } from "@dxos/log";
|
|
9
9
|
import { schema, trace } from "@dxos/protocols";
|
|
@@ -38,14 +38,14 @@ var Messenger = class {
|
|
|
38
38
|
id: traceId
|
|
39
39
|
}), {
|
|
40
40
|
F: __dxlog_file,
|
|
41
|
-
L:
|
|
41
|
+
L: 62,
|
|
42
42
|
S: this,
|
|
43
43
|
C: (f, a) => f(...a)
|
|
44
44
|
});
|
|
45
45
|
this._ctx = new Context({
|
|
46
46
|
onError: (err) => log.catch(err, void 0, {
|
|
47
47
|
F: __dxlog_file,
|
|
48
|
-
L:
|
|
48
|
+
L: 64,
|
|
49
49
|
S: this,
|
|
50
50
|
C: (f, a) => f(...a)
|
|
51
51
|
})
|
|
@@ -55,7 +55,7 @@ var Messenger = class {
|
|
|
55
55
|
from: message.author
|
|
56
56
|
}, {
|
|
57
57
|
F: __dxlog_file,
|
|
58
|
-
L:
|
|
58
|
+
L: 68,
|
|
59
59
|
S: this,
|
|
60
60
|
C: (f, a) => f(...a)
|
|
61
61
|
});
|
|
@@ -66,7 +66,7 @@ var Messenger = class {
|
|
|
66
66
|
id: traceId
|
|
67
67
|
}), {
|
|
68
68
|
F: __dxlog_file,
|
|
69
|
-
L:
|
|
69
|
+
L: 73,
|
|
70
70
|
S: this,
|
|
71
71
|
C: (f, a) => f(...a)
|
|
72
72
|
});
|
|
@@ -79,20 +79,36 @@ var Messenger = class {
|
|
|
79
79
|
await this._ctx.dispose();
|
|
80
80
|
}
|
|
81
81
|
async sendMessage({ author, recipient, payload }) {
|
|
82
|
-
invariant(!this._closed, "Closed"
|
|
82
|
+
invariant(!this._closed, "Closed", {
|
|
83
|
+
F: __dxlog_file,
|
|
84
|
+
L: 85,
|
|
85
|
+
S: this,
|
|
86
|
+
A: [
|
|
87
|
+
"!this._closed",
|
|
88
|
+
"'Closed'"
|
|
89
|
+
]
|
|
90
|
+
});
|
|
83
91
|
const messageContext = this._ctx.derive();
|
|
84
92
|
const reliablePayload = {
|
|
85
93
|
messageId: PublicKey.random(),
|
|
86
94
|
payload
|
|
87
95
|
};
|
|
88
|
-
invariant(!this._onAckCallbacks.has(reliablePayload.messageId)
|
|
96
|
+
invariant(!this._onAckCallbacks.has(reliablePayload.messageId), void 0, {
|
|
97
|
+
F: __dxlog_file,
|
|
98
|
+
L: 92,
|
|
99
|
+
S: this,
|
|
100
|
+
A: [
|
|
101
|
+
"!this._onAckCallbacks.has(reliablePayload.messageId!)",
|
|
102
|
+
""
|
|
103
|
+
]
|
|
104
|
+
});
|
|
89
105
|
log("send message", {
|
|
90
106
|
messageId: reliablePayload.messageId,
|
|
91
107
|
author,
|
|
92
108
|
recipient
|
|
93
109
|
}, {
|
|
94
110
|
F: __dxlog_file,
|
|
95
|
-
L:
|
|
111
|
+
L: 93,
|
|
96
112
|
S: this,
|
|
97
113
|
C: (f, a) => f(...a)
|
|
98
114
|
});
|
|
@@ -107,7 +123,7 @@ var Messenger = class {
|
|
|
107
123
|
messageId: reliablePayload.messageId
|
|
108
124
|
}, {
|
|
109
125
|
F: __dxlog_file,
|
|
110
|
-
L:
|
|
126
|
+
L: 107,
|
|
111
127
|
S: this,
|
|
112
128
|
C: (f, a) => f(...a)
|
|
113
129
|
});
|
|
@@ -119,7 +135,7 @@ var Messenger = class {
|
|
|
119
135
|
err
|
|
120
136
|
}, {
|
|
121
137
|
F: __dxlog_file,
|
|
122
|
-
L:
|
|
138
|
+
L: 109,
|
|
123
139
|
S: this,
|
|
124
140
|
C: (f, a) => f(...a)
|
|
125
141
|
}));
|
|
@@ -129,7 +145,7 @@ var Messenger = class {
|
|
|
129
145
|
messageId: reliablePayload.messageId
|
|
130
146
|
}, {
|
|
131
147
|
F: __dxlog_file,
|
|
132
|
-
L:
|
|
148
|
+
L: 118,
|
|
133
149
|
S: this,
|
|
134
150
|
C: (f, a) => f(...a)
|
|
135
151
|
});
|
|
@@ -154,7 +170,15 @@ var Messenger = class {
|
|
|
154
170
|
* @param payloadType if not specified, onMessage will be subscribed to all types of messages.
|
|
155
171
|
*/
|
|
156
172
|
async listen({ peerId, payloadType, onMessage }) {
|
|
157
|
-
invariant(!this._closed, "Closed"
|
|
173
|
+
invariant(!this._closed, "Closed", {
|
|
174
|
+
F: __dxlog_file,
|
|
175
|
+
L: 149,
|
|
176
|
+
S: this,
|
|
177
|
+
A: [
|
|
178
|
+
"!this._closed",
|
|
179
|
+
"'Closed'"
|
|
180
|
+
]
|
|
181
|
+
});
|
|
158
182
|
await this._signalManager.subscribeMessages(peerId);
|
|
159
183
|
let listeners;
|
|
160
184
|
if (!payloadType) {
|
|
@@ -210,7 +234,15 @@ var Messenger = class {
|
|
|
210
234
|
}
|
|
211
235
|
}
|
|
212
236
|
async _handleReliablePayload({ author, recipient, payload }) {
|
|
213
|
-
invariant(payload.type_url === "dxos.mesh.messaging.ReliablePayload"
|
|
237
|
+
invariant(payload.type_url === "dxos.mesh.messaging.ReliablePayload", void 0, {
|
|
238
|
+
F: __dxlog_file,
|
|
239
|
+
L: 210,
|
|
240
|
+
S: this,
|
|
241
|
+
A: [
|
|
242
|
+
"payload.type_url === 'dxos.mesh.messaging.ReliablePayload'",
|
|
243
|
+
""
|
|
244
|
+
]
|
|
245
|
+
});
|
|
214
246
|
const reliablePayload = ReliablePayload.decode(payload.value, {
|
|
215
247
|
preserveAny: true
|
|
216
248
|
});
|
|
@@ -218,7 +250,7 @@ var Messenger = class {
|
|
|
218
250
|
messageId: reliablePayload.messageId
|
|
219
251
|
}, {
|
|
220
252
|
F: __dxlog_file,
|
|
221
|
-
L:
|
|
253
|
+
L: 213,
|
|
222
254
|
S: this,
|
|
223
255
|
C: (f, a) => f(...a)
|
|
224
256
|
});
|
|
@@ -238,9 +270,16 @@ var Messenger = class {
|
|
|
238
270
|
});
|
|
239
271
|
}
|
|
240
272
|
async _handleAcknowledgement({ payload }) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
273
|
+
invariant(payload.type_url === "dxos.mesh.messaging.Acknowledgement", void 0, {
|
|
274
|
+
F: __dxlog_file,
|
|
275
|
+
L: 235,
|
|
276
|
+
S: this,
|
|
277
|
+
A: [
|
|
278
|
+
"payload.type_url === 'dxos.mesh.messaging.Acknowledgement'",
|
|
279
|
+
""
|
|
280
|
+
]
|
|
281
|
+
});
|
|
282
|
+
this._onAckCallbacks.get(Acknowledgement.decode(payload.value).messageId)?.();
|
|
244
283
|
}
|
|
245
284
|
async _sendAcknowledgement({ author, recipient, messageId }) {
|
|
246
285
|
log("sending ACK", {
|
|
@@ -249,7 +288,7 @@ var Messenger = class {
|
|
|
249
288
|
to: author
|
|
250
289
|
}, {
|
|
251
290
|
F: __dxlog_file,
|
|
252
|
-
L:
|
|
291
|
+
L: 248,
|
|
253
292
|
S: this,
|
|
254
293
|
C: (f, a) => f(...a)
|
|
255
294
|
});
|
|
@@ -288,9 +327,9 @@ var Messenger = class {
|
|
|
288
327
|
};
|
|
289
328
|
|
|
290
329
|
// packages/core/mesh/messaging/src/signal-client/signal-client.ts
|
|
291
|
-
import invariant3 from "tiny-invariant";
|
|
292
330
|
import { DeferredTask, Event, Trigger as Trigger2, asyncTimeout, scheduleTask as scheduleTask2, scheduleTaskInterval, sleep } from "@dxos/async";
|
|
293
331
|
import { Context as Context2, cancelWithContext } from "@dxos/context";
|
|
332
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
294
333
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
295
334
|
import { log as log3 } from "@dxos/log";
|
|
296
335
|
import { trace as trace3 } from "@dxos/protocols";
|
|
@@ -299,8 +338,8 @@ import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet2 } from "@dxos/util
|
|
|
299
338
|
|
|
300
339
|
// packages/core/mesh/messaging/src/signal-client/signal-rpc-client.ts
|
|
301
340
|
import WebSocket from "isomorphic-ws";
|
|
302
|
-
import invariant2 from "tiny-invariant";
|
|
303
341
|
import { Trigger } from "@dxos/async";
|
|
342
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
304
343
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
305
344
|
import { log as log2 } from "@dxos/log";
|
|
306
345
|
import { schema as schema2, trace as trace2 } from "@dxos/protocols";
|
|
@@ -358,7 +397,6 @@ var SignalRPCClient = class {
|
|
|
358
397
|
}
|
|
359
398
|
});
|
|
360
399
|
this._socket.onopen = async () => {
|
|
361
|
-
var _a, _b, _c, _d;
|
|
362
400
|
try {
|
|
363
401
|
await this._rpc.open();
|
|
364
402
|
log2(`RPC open ${this._url}`, void 0, {
|
|
@@ -367,32 +405,30 @@ var SignalRPCClient = class {
|
|
|
367
405
|
S: this,
|
|
368
406
|
C: (f, a) => f(...a)
|
|
369
407
|
});
|
|
370
|
-
|
|
408
|
+
this._callbacks.onConnected?.();
|
|
371
409
|
this._connectTrigger.wake();
|
|
372
410
|
} catch (err) {
|
|
373
|
-
|
|
411
|
+
this._callbacks.onError?.(err);
|
|
374
412
|
}
|
|
375
413
|
};
|
|
376
414
|
this._socket.onclose = async () => {
|
|
377
|
-
var _a, _b;
|
|
378
415
|
log2(`Disconnected ${this._url}`, void 0, {
|
|
379
416
|
F: __dxlog_file2,
|
|
380
417
|
L: 98,
|
|
381
418
|
S: this,
|
|
382
419
|
C: (f, a) => f(...a)
|
|
383
420
|
});
|
|
384
|
-
|
|
421
|
+
this._callbacks.onDisconnected?.();
|
|
385
422
|
await this.close();
|
|
386
423
|
};
|
|
387
424
|
this._socket.onerror = async (event) => {
|
|
388
|
-
var _a, _b, _c, _d, _e;
|
|
389
425
|
if (this._closed) {
|
|
390
426
|
return;
|
|
391
427
|
}
|
|
392
|
-
|
|
428
|
+
this._callbacks.onError?.(event.error ?? new Error(event.message));
|
|
393
429
|
this._connectTrigger.reset();
|
|
394
430
|
try {
|
|
395
|
-
await
|
|
431
|
+
await this._rpc?.close();
|
|
396
432
|
} catch (err) {
|
|
397
433
|
log2.catch(err, void 0, {
|
|
398
434
|
F: __dxlog_file2,
|
|
@@ -402,7 +438,7 @@ var SignalRPCClient = class {
|
|
|
402
438
|
});
|
|
403
439
|
}
|
|
404
440
|
this._closed = true;
|
|
405
|
-
log2.warn(
|
|
441
|
+
log2.warn(event.message ?? "Socket error", {
|
|
406
442
|
url: this._url
|
|
407
443
|
}, {
|
|
408
444
|
F: __dxlog_file2,
|
|
@@ -421,11 +457,10 @@ var SignalRPCClient = class {
|
|
|
421
457
|
});
|
|
422
458
|
}
|
|
423
459
|
async close() {
|
|
424
|
-
var _a, _b;
|
|
425
460
|
this._closed = true;
|
|
426
461
|
try {
|
|
427
|
-
await
|
|
428
|
-
|
|
462
|
+
await this._rpc?.close();
|
|
463
|
+
this._socket?.close();
|
|
429
464
|
} catch (err) {
|
|
430
465
|
log2.warn("close error", err, {
|
|
431
466
|
F: __dxlog_file2,
|
|
@@ -446,8 +481,24 @@ var SignalRPCClient = class {
|
|
|
446
481
|
C: (f, a) => f(...a)
|
|
447
482
|
});
|
|
448
483
|
await this._connectTrigger.wait();
|
|
449
|
-
invariant2(!this._closed, "SignalRPCClient is closed"
|
|
450
|
-
|
|
484
|
+
invariant2(!this._closed, "SignalRPCClient is closed", {
|
|
485
|
+
F: __dxlog_file2,
|
|
486
|
+
L: 138,
|
|
487
|
+
S: this,
|
|
488
|
+
A: [
|
|
489
|
+
"!this._closed",
|
|
490
|
+
"'SignalRPCClient is closed'"
|
|
491
|
+
]
|
|
492
|
+
});
|
|
493
|
+
invariant2(this._rpc, "Rpc is not initialized", {
|
|
494
|
+
F: __dxlog_file2,
|
|
495
|
+
L: 139,
|
|
496
|
+
S: this,
|
|
497
|
+
A: [
|
|
498
|
+
"this._rpc",
|
|
499
|
+
"'Rpc is not initialized'"
|
|
500
|
+
]
|
|
501
|
+
});
|
|
451
502
|
const swarmStream = this._rpc.rpc.Signal.join({
|
|
452
503
|
swarm: topic.asUint8Array(),
|
|
453
504
|
peer: peerId.asUint8Array()
|
|
@@ -464,9 +515,25 @@ var SignalRPCClient = class {
|
|
|
464
515
|
S: this,
|
|
465
516
|
C: (f, a) => f(...a)
|
|
466
517
|
});
|
|
467
|
-
invariant2(!this._closed, "SignalRPCClient is closed"
|
|
518
|
+
invariant2(!this._closed, "SignalRPCClient is closed", {
|
|
519
|
+
F: __dxlog_file2,
|
|
520
|
+
L: 150,
|
|
521
|
+
S: this,
|
|
522
|
+
A: [
|
|
523
|
+
"!this._closed",
|
|
524
|
+
"'SignalRPCClient is closed'"
|
|
525
|
+
]
|
|
526
|
+
});
|
|
468
527
|
await this._connectTrigger.wait();
|
|
469
|
-
invariant2(this._rpc, "Rpc is not initialized"
|
|
528
|
+
invariant2(this._rpc, "Rpc is not initialized", {
|
|
529
|
+
F: __dxlog_file2,
|
|
530
|
+
L: 152,
|
|
531
|
+
S: this,
|
|
532
|
+
A: [
|
|
533
|
+
"this._rpc",
|
|
534
|
+
"'Rpc is not initialized'"
|
|
535
|
+
]
|
|
536
|
+
});
|
|
470
537
|
const messageStream = this._rpc.rpc.Signal.receiveMessages({
|
|
471
538
|
peer: peerId.asUint8Array()
|
|
472
539
|
});
|
|
@@ -484,9 +551,25 @@ var SignalRPCClient = class {
|
|
|
484
551
|
S: this,
|
|
485
552
|
C: (f, a) => f(...a)
|
|
486
553
|
});
|
|
487
|
-
invariant2(!this._closed, "SignalRPCClient is closed"
|
|
554
|
+
invariant2(!this._closed, "SignalRPCClient is closed", {
|
|
555
|
+
F: __dxlog_file2,
|
|
556
|
+
L: 162,
|
|
557
|
+
S: this,
|
|
558
|
+
A: [
|
|
559
|
+
"!this._closed",
|
|
560
|
+
"'SignalRPCClient is closed'"
|
|
561
|
+
]
|
|
562
|
+
});
|
|
488
563
|
await this._connectTrigger.wait();
|
|
489
|
-
invariant2(this._rpc, "Rpc is not initialized"
|
|
564
|
+
invariant2(this._rpc, "Rpc is not initialized", {
|
|
565
|
+
F: __dxlog_file2,
|
|
566
|
+
L: 164,
|
|
567
|
+
S: this,
|
|
568
|
+
A: [
|
|
569
|
+
"this._rpc",
|
|
570
|
+
"'Rpc is not initialized'"
|
|
571
|
+
]
|
|
572
|
+
});
|
|
490
573
|
await this._rpc.rpc.Signal.sendMessage({
|
|
491
574
|
author: author.asUint8Array(),
|
|
492
575
|
recipient: recipient.asUint8Array(),
|
|
@@ -512,8 +595,8 @@ var SignalClient = class {
|
|
|
512
595
|
this._onSwarmEvent = _onSwarmEvent;
|
|
513
596
|
this._state = SignalState.CLOSED;
|
|
514
597
|
this._reconnectAfter = DEFAULT_RECONNECT_TIMEOUT;
|
|
515
|
-
this._connectionStarted = new Date();
|
|
516
|
-
this._lastStateChange = new Date();
|
|
598
|
+
this._connectionStarted = /* @__PURE__ */ new Date();
|
|
599
|
+
this._lastStateChange = /* @__PURE__ */ new Date();
|
|
517
600
|
this._clientReady = new Trigger2();
|
|
518
601
|
this.statusChanged = new Event();
|
|
519
602
|
this.commandTrace = new Event();
|
|
@@ -539,7 +622,7 @@ var SignalClient = class {
|
|
|
539
622
|
id: this._instanceId
|
|
540
623
|
}), {
|
|
541
624
|
F: __dxlog_file3,
|
|
542
|
-
L:
|
|
625
|
+
L: 135,
|
|
543
626
|
S: this,
|
|
544
627
|
C: (f, a) => f(...a)
|
|
545
628
|
});
|
|
@@ -551,14 +634,13 @@ var SignalClient = class {
|
|
|
551
634
|
}
|
|
552
635
|
this._ctx = new Context2({
|
|
553
636
|
onError: (err) => {
|
|
554
|
-
|
|
555
|
-
if (this._state === SignalState.CLOSED || ((_a = this._ctx) == null ? void 0 : _a.disposed)) {
|
|
637
|
+
if (this._state === SignalState.CLOSED || this._ctx?.disposed) {
|
|
556
638
|
return;
|
|
557
639
|
}
|
|
558
640
|
if (this._state === SignalState.CONNECTED) {
|
|
559
641
|
log3.warn("SignalClient error:", err, {
|
|
560
642
|
F: __dxlog_file3,
|
|
561
|
-
L:
|
|
643
|
+
L: 147,
|
|
562
644
|
S: this,
|
|
563
645
|
C: (f, a) => f(...a)
|
|
564
646
|
});
|
|
@@ -585,16 +667,15 @@ var SignalClient = class {
|
|
|
585
667
|
id: this._instanceId
|
|
586
668
|
}), {
|
|
587
669
|
F: __dxlog_file3,
|
|
588
|
-
L:
|
|
670
|
+
L: 176,
|
|
589
671
|
S: this,
|
|
590
672
|
C: (f, a) => f(...a)
|
|
591
673
|
});
|
|
592
674
|
}
|
|
593
675
|
async close() {
|
|
594
|
-
var _a, _b;
|
|
595
676
|
log3("closing...", void 0, {
|
|
596
677
|
F: __dxlog_file3,
|
|
597
|
-
L:
|
|
678
|
+
L: 180,
|
|
598
679
|
S: this,
|
|
599
680
|
C: (f, a) => f(...a)
|
|
600
681
|
});
|
|
@@ -603,24 +684,23 @@ var SignalClient = class {
|
|
|
603
684
|
].includes(this._state)) {
|
|
604
685
|
return;
|
|
605
686
|
}
|
|
606
|
-
await
|
|
687
|
+
await this._ctx?.dispose();
|
|
607
688
|
this._clientReady.reset();
|
|
608
|
-
await
|
|
689
|
+
await this._client?.close();
|
|
609
690
|
this._client = void 0;
|
|
610
691
|
this._setState(SignalState.CLOSED);
|
|
611
692
|
log3("closed", void 0, {
|
|
612
693
|
F: __dxlog_file3,
|
|
613
|
-
L:
|
|
694
|
+
L: 191,
|
|
614
695
|
S: this,
|
|
615
696
|
C: (f, a) => f(...a)
|
|
616
697
|
});
|
|
617
698
|
}
|
|
618
699
|
getStatus() {
|
|
619
|
-
var _a;
|
|
620
700
|
return {
|
|
621
701
|
host: this._host,
|
|
622
702
|
state: this._state,
|
|
623
|
-
error:
|
|
703
|
+
error: this._lastError?.message,
|
|
624
704
|
reconnectIn: this._reconnectAfter,
|
|
625
705
|
connectionStarted: this._connectionStarted,
|
|
626
706
|
lastStateChange: this._lastStateChange
|
|
@@ -632,7 +712,7 @@ var SignalClient = class {
|
|
|
632
712
|
peerId
|
|
633
713
|
}, {
|
|
634
714
|
F: __dxlog_file3,
|
|
635
|
-
L:
|
|
715
|
+
L: 206,
|
|
636
716
|
S: this,
|
|
637
717
|
C: (f, a) => f(...a)
|
|
638
718
|
});
|
|
@@ -644,21 +724,20 @@ var SignalClient = class {
|
|
|
644
724
|
this._reconcileTask.schedule();
|
|
645
725
|
}
|
|
646
726
|
async leave({ topic, peerId }) {
|
|
647
|
-
var _a;
|
|
648
727
|
this._performance.leaveCounter++;
|
|
649
728
|
log3("leaving", {
|
|
650
729
|
topic,
|
|
651
730
|
peerId
|
|
652
731
|
}, {
|
|
653
732
|
F: __dxlog_file3,
|
|
654
|
-
L:
|
|
733
|
+
L: 214,
|
|
655
734
|
S: this,
|
|
656
735
|
C: (f, a) => f(...a)
|
|
657
736
|
});
|
|
658
|
-
|
|
737
|
+
this._swarmStreams.get({
|
|
659
738
|
topic,
|
|
660
739
|
peerId
|
|
661
|
-
})
|
|
740
|
+
})?.close();
|
|
662
741
|
this._swarmStreams.delete({
|
|
663
742
|
topic,
|
|
664
743
|
peerId
|
|
@@ -671,7 +750,15 @@ var SignalClient = class {
|
|
|
671
750
|
async sendMessage(msg) {
|
|
672
751
|
this._performance.sentMessages++;
|
|
673
752
|
await this._clientReady.wait();
|
|
674
|
-
invariant3(this._state === SignalState.CONNECTED, "Not connected to Signal Server"
|
|
753
|
+
invariant3(this._state === SignalState.CONNECTED, "Not connected to Signal Server", {
|
|
754
|
+
F: __dxlog_file3,
|
|
755
|
+
L: 224,
|
|
756
|
+
S: this,
|
|
757
|
+
A: [
|
|
758
|
+
"this._state === SignalState.CONNECTED",
|
|
759
|
+
"'Not connected to Signal Server'"
|
|
760
|
+
]
|
|
761
|
+
});
|
|
675
762
|
await this._client.sendMessage(msg);
|
|
676
763
|
}
|
|
677
764
|
async subscribeMessages(peerId) {
|
|
@@ -679,7 +766,7 @@ var SignalClient = class {
|
|
|
679
766
|
peerId
|
|
680
767
|
}, {
|
|
681
768
|
F: __dxlog_file3,
|
|
682
|
-
L:
|
|
769
|
+
L: 229,
|
|
683
770
|
S: this,
|
|
684
771
|
C: (f, a) => f(...a)
|
|
685
772
|
});
|
|
@@ -689,19 +776,18 @@ var SignalClient = class {
|
|
|
689
776
|
this._reconcileTask.schedule();
|
|
690
777
|
}
|
|
691
778
|
async unsubscribeMessages(peerId) {
|
|
692
|
-
var _a;
|
|
693
779
|
log3("unsubscribing from messages", {
|
|
694
780
|
peerId
|
|
695
781
|
}, {
|
|
696
782
|
F: __dxlog_file3,
|
|
697
|
-
L:
|
|
783
|
+
L: 235,
|
|
698
784
|
S: this,
|
|
699
785
|
C: (f, a) => f(...a)
|
|
700
786
|
});
|
|
701
787
|
this._subscribedMessages.delete({
|
|
702
788
|
peerId
|
|
703
789
|
});
|
|
704
|
-
|
|
790
|
+
this._messageStreams.get(peerId)?.close();
|
|
705
791
|
this._messageStreams.delete(peerId);
|
|
706
792
|
}
|
|
707
793
|
_scheduleReconcileAfterError() {
|
|
@@ -711,12 +797,12 @@ var SignalClient = class {
|
|
|
711
797
|
}
|
|
712
798
|
_setState(newState) {
|
|
713
799
|
this._state = newState;
|
|
714
|
-
this._lastStateChange = new Date();
|
|
800
|
+
this._lastStateChange = /* @__PURE__ */ new Date();
|
|
715
801
|
log3("signal state changed", {
|
|
716
802
|
status: this.getStatus()
|
|
717
803
|
}, {
|
|
718
804
|
F: __dxlog_file3,
|
|
719
|
-
L:
|
|
805
|
+
L: 254,
|
|
720
806
|
S: this,
|
|
721
807
|
C: (f, a) => f(...a)
|
|
722
808
|
});
|
|
@@ -728,22 +814,30 @@ var SignalClient = class {
|
|
|
728
814
|
state: this._state
|
|
729
815
|
}, {
|
|
730
816
|
F: __dxlog_file3,
|
|
731
|
-
L:
|
|
817
|
+
L: 259,
|
|
732
818
|
S: this,
|
|
733
819
|
C: (f, a) => f(...a)
|
|
734
820
|
});
|
|
735
|
-
invariant3(!this._client, "Client already created"
|
|
736
|
-
|
|
821
|
+
invariant3(!this._client, "Client already created", {
|
|
822
|
+
F: __dxlog_file3,
|
|
823
|
+
L: 260,
|
|
824
|
+
S: this,
|
|
825
|
+
A: [
|
|
826
|
+
"!this._client",
|
|
827
|
+
"'Client already created'"
|
|
828
|
+
]
|
|
829
|
+
});
|
|
830
|
+
this._connectionStarted = /* @__PURE__ */ new Date();
|
|
737
831
|
this._connectionCtx = this._ctx.derive();
|
|
738
|
-
this._connectionCtx.onDispose(() => {
|
|
832
|
+
this._connectionCtx.onDispose(async () => {
|
|
739
833
|
log3("connection context disposed", void 0, {
|
|
740
834
|
F: __dxlog_file3,
|
|
741
|
-
L:
|
|
835
|
+
L: 267,
|
|
742
836
|
S: this,
|
|
743
837
|
C: (f, a) => f(...a)
|
|
744
838
|
});
|
|
745
|
-
Array.from(this._swarmStreams.values()).
|
|
746
|
-
Array.from(this._messageStreams.values()).
|
|
839
|
+
await Promise.all(Array.from(this._swarmStreams.values()).map((stream) => stream.close()));
|
|
840
|
+
await Promise.all(Array.from(this._messageStreams.values()).map((stream) => stream.close()));
|
|
747
841
|
this._swarmStreams.clear();
|
|
748
842
|
this._messageStreams.clear();
|
|
749
843
|
});
|
|
@@ -754,7 +848,7 @@ var SignalClient = class {
|
|
|
754
848
|
onConnected: () => {
|
|
755
849
|
log3("socket connected", void 0, {
|
|
756
850
|
F: __dxlog_file3,
|
|
757
|
-
L:
|
|
851
|
+
L: 279,
|
|
758
852
|
S: this,
|
|
759
853
|
C: (f, a) => f(...a)
|
|
760
854
|
});
|
|
@@ -769,7 +863,7 @@ var SignalClient = class {
|
|
|
769
863
|
state: this._state
|
|
770
864
|
}, {
|
|
771
865
|
F: __dxlog_file3,
|
|
772
|
-
L:
|
|
866
|
+
L: 288,
|
|
773
867
|
S: this,
|
|
774
868
|
C: (f, a) => f(...a)
|
|
775
869
|
});
|
|
@@ -789,7 +883,7 @@ var SignalClient = class {
|
|
|
789
883
|
state: this._state
|
|
790
884
|
}, {
|
|
791
885
|
F: __dxlog_file3,
|
|
792
|
-
L:
|
|
886
|
+
L: 303,
|
|
793
887
|
S: this,
|
|
794
888
|
C: (f, a) => f(...a)
|
|
795
889
|
});
|
|
@@ -816,12 +910,11 @@ var SignalClient = class {
|
|
|
816
910
|
this._reconnectAfter = Math.min(this._reconnectAfter, MAX_RECONNECT_TIMEOUT);
|
|
817
911
|
}
|
|
818
912
|
async _reconnect() {
|
|
819
|
-
var _a, _b;
|
|
820
913
|
log3(`reconnecting in ${this._reconnectAfter}ms`, {
|
|
821
914
|
state: this._state
|
|
822
915
|
}, {
|
|
823
916
|
F: __dxlog_file3,
|
|
824
|
-
L:
|
|
917
|
+
L: 330,
|
|
825
918
|
S: this,
|
|
826
919
|
C: (f, a) => f(...a)
|
|
827
920
|
});
|
|
@@ -829,7 +922,7 @@ var SignalClient = class {
|
|
|
829
922
|
if (this._state === SignalState.RECONNECTING) {
|
|
830
923
|
log3.warn("Signal api already reconnecting.", void 0, {
|
|
831
924
|
F: __dxlog_file3,
|
|
832
|
-
L:
|
|
925
|
+
L: 334,
|
|
833
926
|
S: this,
|
|
834
927
|
C: (f, a) => f(...a)
|
|
835
928
|
});
|
|
@@ -839,8 +932,8 @@ var SignalClient = class {
|
|
|
839
932
|
return;
|
|
840
933
|
}
|
|
841
934
|
this._clientReady.reset();
|
|
842
|
-
await
|
|
843
|
-
|
|
935
|
+
await this._connectionCtx?.dispose();
|
|
936
|
+
this._client?.close().catch(() => {
|
|
844
937
|
});
|
|
845
938
|
this._client = void 0;
|
|
846
939
|
await cancelWithContext(this._ctx, sleep(this._reconnectAfter));
|
|
@@ -848,10 +941,17 @@ var SignalClient = class {
|
|
|
848
941
|
this._createClient();
|
|
849
942
|
}
|
|
850
943
|
async _reconcileSwarmSubscriptions() {
|
|
851
|
-
var _a;
|
|
852
944
|
await asyncTimeout(cancelWithContext(this._connectionCtx, this._clientReady.wait()), 5e3);
|
|
853
945
|
const client = this._client;
|
|
854
|
-
invariant3(this._state === SignalState.CONNECTED, "Not connected to Signal Server"
|
|
946
|
+
invariant3(this._state === SignalState.CONNECTED, "Not connected to Signal Server", {
|
|
947
|
+
F: __dxlog_file3,
|
|
948
|
+
L: 359,
|
|
949
|
+
S: this,
|
|
950
|
+
A: [
|
|
951
|
+
"this._state === SignalState.CONNECTED",
|
|
952
|
+
"'Not connected to Signal Server'"
|
|
953
|
+
]
|
|
954
|
+
});
|
|
855
955
|
for (const { topic, peerId } of this._swarmStreams.keys()) {
|
|
856
956
|
if (this._joinedTopics.has({
|
|
857
957
|
topic,
|
|
@@ -859,10 +959,10 @@ var SignalClient = class {
|
|
|
859
959
|
})) {
|
|
860
960
|
continue;
|
|
861
961
|
}
|
|
862
|
-
|
|
962
|
+
this._swarmStreams.get({
|
|
863
963
|
topic,
|
|
864
964
|
peerId
|
|
865
|
-
})
|
|
965
|
+
})?.close();
|
|
866
966
|
this._swarmStreams.delete({
|
|
867
967
|
topic,
|
|
868
968
|
peerId
|
|
@@ -884,7 +984,7 @@ var SignalClient = class {
|
|
|
884
984
|
swarmEvent
|
|
885
985
|
}, {
|
|
886
986
|
F: __dxlog_file3,
|
|
887
|
-
L:
|
|
987
|
+
L: 386,
|
|
888
988
|
S: this,
|
|
889
989
|
C: (f, a) => f(...a)
|
|
890
990
|
});
|
|
@@ -900,17 +1000,24 @@ var SignalClient = class {
|
|
|
900
1000
|
}
|
|
901
1001
|
}
|
|
902
1002
|
async _reconcileMessageSubscriptions() {
|
|
903
|
-
var _a;
|
|
904
1003
|
await asyncTimeout(cancelWithContext(this._connectionCtx, this._clientReady.wait()), 5e3);
|
|
905
1004
|
const client = this._client;
|
|
906
|
-
invariant3(this._state === SignalState.CONNECTED, "Not connected to Signal Server"
|
|
1005
|
+
invariant3(this._state === SignalState.CONNECTED, "Not connected to Signal Server", {
|
|
1006
|
+
F: __dxlog_file3,
|
|
1007
|
+
L: 399,
|
|
1008
|
+
S: this,
|
|
1009
|
+
A: [
|
|
1010
|
+
"this._state === SignalState.CONNECTED",
|
|
1011
|
+
"'Not connected to Signal Server'"
|
|
1012
|
+
]
|
|
1013
|
+
});
|
|
907
1014
|
for (const peerId of this._messageStreams.keys()) {
|
|
908
1015
|
if (this._subscribedMessages.has({
|
|
909
1016
|
peerId
|
|
910
1017
|
})) {
|
|
911
1018
|
continue;
|
|
912
1019
|
}
|
|
913
|
-
|
|
1020
|
+
this._messageStreams.get(peerId)?.close();
|
|
914
1021
|
this._messageStreams.delete(peerId);
|
|
915
1022
|
}
|
|
916
1023
|
for (const { peerId } of this._subscribedMessages.values()) {
|
|
@@ -932,11 +1039,12 @@ var SignalClient = class {
|
|
|
932
1039
|
};
|
|
933
1040
|
|
|
934
1041
|
// packages/core/mesh/messaging/src/signal-manager/memory-signal-manager.ts
|
|
935
|
-
import
|
|
936
|
-
import { Event as Event2 } from "@dxos/async";
|
|
1042
|
+
import { Event as Event2, Trigger as Trigger3 } from "@dxos/async";
|
|
937
1043
|
import { Context as Context3 } from "@dxos/context";
|
|
1044
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
938
1045
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
939
1046
|
import { log as log4 } from "@dxos/log";
|
|
1047
|
+
import { schema as schema3 } from "@dxos/protocols";
|
|
940
1048
|
import { ComplexMap as ComplexMap3, ComplexSet as ComplexSet3 } from "@dxos/util";
|
|
941
1049
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/messaging/src/signal-manager/memory-signal-manager.ts";
|
|
942
1050
|
var MemorySignalManagerContext = class {
|
|
@@ -958,6 +1066,7 @@ var MemorySignalManager = class {
|
|
|
958
1066
|
this.swarmEvent = new Event2();
|
|
959
1067
|
this.onMessage = new Event2();
|
|
960
1068
|
this._joinedSwarms = new ComplexSet3(({ topic, peerId }) => topic.toHex() + peerId.toHex());
|
|
1069
|
+
this._freezeTrigger = new Trigger3().wake();
|
|
961
1070
|
this._ctx = new Context3();
|
|
962
1071
|
this._ctx.onDispose(this._context.swarmEvent.on((data) => this.swarmEvent.emit(data)));
|
|
963
1072
|
}
|
|
@@ -988,7 +1097,15 @@ var MemorySignalManager = class {
|
|
|
988
1097
|
return [];
|
|
989
1098
|
}
|
|
990
1099
|
async join({ topic, peerId }) {
|
|
991
|
-
invariant4(!this._ctx.disposed, "Closed"
|
|
1100
|
+
invariant4(!this._ctx.disposed, "Closed", {
|
|
1101
|
+
F: __dxlog_file4,
|
|
1102
|
+
L: 104,
|
|
1103
|
+
S: this,
|
|
1104
|
+
A: [
|
|
1105
|
+
"!this._ctx.disposed",
|
|
1106
|
+
"'Closed'"
|
|
1107
|
+
]
|
|
1108
|
+
});
|
|
992
1109
|
this._joinedSwarms.add({
|
|
993
1110
|
topic,
|
|
994
1111
|
peerId
|
|
@@ -1002,7 +1119,7 @@ var MemorySignalManager = class {
|
|
|
1002
1119
|
swarmEvent: {
|
|
1003
1120
|
peerAvailable: {
|
|
1004
1121
|
peer: peerId.asUint8Array(),
|
|
1005
|
-
since: new Date()
|
|
1122
|
+
since: /* @__PURE__ */ new Date()
|
|
1006
1123
|
}
|
|
1007
1124
|
}
|
|
1008
1125
|
});
|
|
@@ -1013,7 +1130,7 @@ var MemorySignalManager = class {
|
|
|
1013
1130
|
swarmEvent: {
|
|
1014
1131
|
peerAvailable: {
|
|
1015
1132
|
peer: peerId2.asUint8Array(),
|
|
1016
|
-
since: new Date()
|
|
1133
|
+
since: /* @__PURE__ */ new Date()
|
|
1017
1134
|
}
|
|
1018
1135
|
}
|
|
1019
1136
|
});
|
|
@@ -1021,7 +1138,15 @@ var MemorySignalManager = class {
|
|
|
1021
1138
|
}
|
|
1022
1139
|
}
|
|
1023
1140
|
async leave({ topic, peerId }) {
|
|
1024
|
-
invariant4(!this._ctx.disposed, "Closed"
|
|
1141
|
+
invariant4(!this._ctx.disposed, "Closed", {
|
|
1142
|
+
F: __dxlog_file4,
|
|
1143
|
+
L: 140,
|
|
1144
|
+
S: this,
|
|
1145
|
+
A: [
|
|
1146
|
+
"!this._ctx.disposed",
|
|
1147
|
+
"'Closed'"
|
|
1148
|
+
]
|
|
1149
|
+
});
|
|
1025
1150
|
this._joinedSwarms.delete({
|
|
1026
1151
|
topic,
|
|
1027
1152
|
peerId
|
|
@@ -1041,35 +1166,105 @@ var MemorySignalManager = class {
|
|
|
1041
1166
|
});
|
|
1042
1167
|
}
|
|
1043
1168
|
async sendMessage({ author, recipient, payload }) {
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1169
|
+
log4("send message", {
|
|
1170
|
+
author,
|
|
1171
|
+
recipient,
|
|
1172
|
+
...dec(payload)
|
|
1173
|
+
}, {
|
|
1174
|
+
F: __dxlog_file4,
|
|
1175
|
+
L: 160,
|
|
1176
|
+
S: this,
|
|
1177
|
+
C: (f, a) => f(...a)
|
|
1178
|
+
});
|
|
1179
|
+
invariant4(recipient, void 0, {
|
|
1180
|
+
F: __dxlog_file4,
|
|
1181
|
+
L: 162,
|
|
1182
|
+
S: this,
|
|
1183
|
+
A: [
|
|
1184
|
+
"recipient",
|
|
1185
|
+
""
|
|
1186
|
+
]
|
|
1187
|
+
});
|
|
1188
|
+
invariant4(!this._ctx.disposed, "Closed", {
|
|
1189
|
+
F: __dxlog_file4,
|
|
1190
|
+
L: 163,
|
|
1191
|
+
S: this,
|
|
1192
|
+
A: [
|
|
1193
|
+
"!this._ctx.disposed",
|
|
1194
|
+
"'Closed'"
|
|
1195
|
+
]
|
|
1196
|
+
});
|
|
1197
|
+
await this._freezeTrigger.wait();
|
|
1198
|
+
const remote = this._context.connections.get(recipient);
|
|
1199
|
+
if (!remote) {
|
|
1048
1200
|
log4.warn("recipient is not subscribed for messages", {
|
|
1049
1201
|
author,
|
|
1050
1202
|
recipient
|
|
1051
1203
|
}, {
|
|
1052
1204
|
F: __dxlog_file4,
|
|
1053
|
-
L:
|
|
1205
|
+
L: 169,
|
|
1054
1206
|
S: this,
|
|
1055
1207
|
C: (f, a) => f(...a)
|
|
1056
1208
|
});
|
|
1057
1209
|
return;
|
|
1058
1210
|
}
|
|
1059
|
-
if (
|
|
1060
|
-
|
|
1211
|
+
if (remote._ctx.disposed) {
|
|
1212
|
+
log4.warn("recipient is disposed", {
|
|
1213
|
+
author,
|
|
1214
|
+
recipient
|
|
1215
|
+
}, {
|
|
1216
|
+
F: __dxlog_file4,
|
|
1217
|
+
L: 174,
|
|
1218
|
+
S: this,
|
|
1219
|
+
C: (f, a) => f(...a)
|
|
1220
|
+
});
|
|
1221
|
+
return;
|
|
1222
|
+
}
|
|
1223
|
+
remote._freezeTrigger.wait().then(() => {
|
|
1224
|
+
if (remote._ctx.disposed) {
|
|
1225
|
+
log4.warn("recipient is disposed", {
|
|
1226
|
+
author,
|
|
1227
|
+
recipient
|
|
1228
|
+
}, {
|
|
1229
|
+
F: __dxlog_file4,
|
|
1230
|
+
L: 182,
|
|
1231
|
+
S: this,
|
|
1232
|
+
C: (f, a) => f(...a)
|
|
1233
|
+
});
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
log4("receive message", {
|
|
1237
|
+
author,
|
|
1238
|
+
recipient,
|
|
1239
|
+
...dec(payload)
|
|
1240
|
+
}, {
|
|
1241
|
+
F: __dxlog_file4,
|
|
1242
|
+
L: 186,
|
|
1243
|
+
S: this,
|
|
1244
|
+
C: (f, a) => f(...a)
|
|
1245
|
+
});
|
|
1246
|
+
remote.onMessage.emit({
|
|
1061
1247
|
author,
|
|
1062
1248
|
recipient,
|
|
1063
1249
|
payload
|
|
1064
1250
|
});
|
|
1065
|
-
}
|
|
1251
|
+
}).catch((err) => {
|
|
1252
|
+
log4.error("error while waiting for freeze", {
|
|
1253
|
+
err
|
|
1254
|
+
}, {
|
|
1255
|
+
F: __dxlog_file4,
|
|
1256
|
+
L: 191,
|
|
1257
|
+
S: this,
|
|
1258
|
+
C: (f, a) => f(...a)
|
|
1259
|
+
});
|
|
1260
|
+
});
|
|
1066
1261
|
}
|
|
1067
1262
|
async subscribeMessages(peerId) {
|
|
1068
1263
|
log4("subscribing", {
|
|
1069
1264
|
peerId
|
|
1070
1265
|
}, {
|
|
1071
1266
|
F: __dxlog_file4,
|
|
1072
|
-
L:
|
|
1267
|
+
L: 196,
|
|
1073
1268
|
S: this,
|
|
1074
1269
|
C: (f, a) => f(...a)
|
|
1075
1270
|
});
|
|
@@ -1080,18 +1275,37 @@ var MemorySignalManager = class {
|
|
|
1080
1275
|
peerId
|
|
1081
1276
|
}, {
|
|
1082
1277
|
F: __dxlog_file4,
|
|
1083
|
-
L:
|
|
1278
|
+
L: 201,
|
|
1084
1279
|
S: this,
|
|
1085
1280
|
C: (f, a) => f(...a)
|
|
1086
1281
|
});
|
|
1087
1282
|
this._context.connections.delete(peerId);
|
|
1088
1283
|
}
|
|
1284
|
+
freeze() {
|
|
1285
|
+
this._freezeTrigger.reset();
|
|
1286
|
+
}
|
|
1287
|
+
unfreeze() {
|
|
1288
|
+
this._freezeTrigger.wake();
|
|
1289
|
+
}
|
|
1290
|
+
};
|
|
1291
|
+
var dec = (payload) => {
|
|
1292
|
+
if (!payload.type_url.endsWith("ReliablePayload")) {
|
|
1293
|
+
return {};
|
|
1294
|
+
}
|
|
1295
|
+
const relPayload = schema3.getCodecForType("dxos.mesh.messaging.ReliablePayload").decode(payload.value);
|
|
1296
|
+
if (typeof relPayload?.payload?.data === "object") {
|
|
1297
|
+
return {
|
|
1298
|
+
payload: Object.keys(relPayload?.payload?.data)[0],
|
|
1299
|
+
sessionId: relPayload?.payload?.sessionId
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
return {};
|
|
1089
1303
|
};
|
|
1090
1304
|
|
|
1091
1305
|
// packages/core/mesh/messaging/src/signal-manager/websocket-signal-manager.ts
|
|
1092
|
-
import invariant5 from "tiny-invariant";
|
|
1093
1306
|
import { Event as Event3, synchronized } from "@dxos/async";
|
|
1094
1307
|
import { Context as Context4 } from "@dxos/context";
|
|
1308
|
+
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1095
1309
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1096
1310
|
import { log as log5 } from "@dxos/log";
|
|
1097
1311
|
import { trace as trace4 } from "@dxos/protocols";
|
|
@@ -1121,7 +1335,7 @@ var WebsocketSignalManager = class {
|
|
|
1121
1335
|
hosts: this._hosts
|
|
1122
1336
|
}, {
|
|
1123
1337
|
F: __dxlog_file5,
|
|
1124
|
-
L:
|
|
1338
|
+
L: 46,
|
|
1125
1339
|
S: this,
|
|
1126
1340
|
C: (f, a) => f(...a)
|
|
1127
1341
|
});
|
|
@@ -1143,7 +1357,7 @@ var WebsocketSignalManager = class {
|
|
|
1143
1357
|
hosts: this._hosts
|
|
1144
1358
|
}, {
|
|
1145
1359
|
F: __dxlog_file5,
|
|
1146
|
-
L:
|
|
1360
|
+
L: 68,
|
|
1147
1361
|
S: this,
|
|
1148
1362
|
C: (f, a) => f(...a)
|
|
1149
1363
|
});
|
|
@@ -1151,7 +1365,7 @@ var WebsocketSignalManager = class {
|
|
|
1151
1365
|
id: this._instanceId
|
|
1152
1366
|
}), {
|
|
1153
1367
|
F: __dxlog_file5,
|
|
1154
|
-
L:
|
|
1368
|
+
L: 69,
|
|
1155
1369
|
S: this,
|
|
1156
1370
|
C: (f, a) => f(...a)
|
|
1157
1371
|
});
|
|
@@ -1164,7 +1378,7 @@ var WebsocketSignalManager = class {
|
|
|
1164
1378
|
id: this._instanceId
|
|
1165
1379
|
}), {
|
|
1166
1380
|
F: __dxlog_file5,
|
|
1167
|
-
L:
|
|
1381
|
+
L: 76,
|
|
1168
1382
|
S: this,
|
|
1169
1383
|
C: (f, a) => f(...a)
|
|
1170
1384
|
});
|
|
@@ -1186,11 +1400,19 @@ var WebsocketSignalManager = class {
|
|
|
1186
1400
|
peerId
|
|
1187
1401
|
}, {
|
|
1188
1402
|
F: __dxlog_file5,
|
|
1189
|
-
L:
|
|
1403
|
+
L: 96,
|
|
1190
1404
|
S: this,
|
|
1191
1405
|
C: (f, a) => f(...a)
|
|
1192
1406
|
});
|
|
1193
|
-
invariant5(this._opened, "Closed"
|
|
1407
|
+
invariant5(this._opened, "Closed", {
|
|
1408
|
+
F: __dxlog_file5,
|
|
1409
|
+
L: 97,
|
|
1410
|
+
S: this,
|
|
1411
|
+
A: [
|
|
1412
|
+
"this._opened",
|
|
1413
|
+
"'Closed'"
|
|
1414
|
+
]
|
|
1415
|
+
});
|
|
1194
1416
|
await this._forEachServer((server) => server.join({
|
|
1195
1417
|
topic,
|
|
1196
1418
|
peerId
|
|
@@ -1202,11 +1424,19 @@ var WebsocketSignalManager = class {
|
|
|
1202
1424
|
peerId
|
|
1203
1425
|
}, {
|
|
1204
1426
|
F: __dxlog_file5,
|
|
1205
|
-
L:
|
|
1427
|
+
L: 103,
|
|
1206
1428
|
S: this,
|
|
1207
1429
|
C: (f, a) => f(...a)
|
|
1208
1430
|
});
|
|
1209
|
-
invariant5(this._opened, "Closed"
|
|
1431
|
+
invariant5(this._opened, "Closed", {
|
|
1432
|
+
F: __dxlog_file5,
|
|
1433
|
+
L: 104,
|
|
1434
|
+
S: this,
|
|
1435
|
+
A: [
|
|
1436
|
+
"this._opened",
|
|
1437
|
+
"'Closed'"
|
|
1438
|
+
]
|
|
1439
|
+
});
|
|
1210
1440
|
await this._forEachServer((server) => server.leave({
|
|
1211
1441
|
topic,
|
|
1212
1442
|
peerId
|
|
@@ -1215,11 +1445,19 @@ var WebsocketSignalManager = class {
|
|
|
1215
1445
|
async sendMessage({ author, recipient, payload }) {
|
|
1216
1446
|
log5(`Signal ${recipient}`, void 0, {
|
|
1217
1447
|
F: __dxlog_file5,
|
|
1218
|
-
L:
|
|
1448
|
+
L: 118,
|
|
1219
1449
|
S: this,
|
|
1220
1450
|
C: (f, a) => f(...a)
|
|
1221
1451
|
});
|
|
1222
|
-
invariant5(this._opened, "Closed"
|
|
1452
|
+
invariant5(this._opened, "Closed", {
|
|
1453
|
+
F: __dxlog_file5,
|
|
1454
|
+
L: 119,
|
|
1455
|
+
S: this,
|
|
1456
|
+
A: [
|
|
1457
|
+
"this._opened",
|
|
1458
|
+
"'Closed'"
|
|
1459
|
+
]
|
|
1460
|
+
});
|
|
1223
1461
|
void this._forEachServer(async (server) => {
|
|
1224
1462
|
void server.sendMessage({
|
|
1225
1463
|
author,
|
|
@@ -1227,7 +1465,7 @@ var WebsocketSignalManager = class {
|
|
|
1227
1465
|
payload
|
|
1228
1466
|
}).catch((err) => log5(err, void 0, {
|
|
1229
1467
|
F: __dxlog_file5,
|
|
1230
|
-
L:
|
|
1468
|
+
L: 122,
|
|
1231
1469
|
S: this,
|
|
1232
1470
|
C: (f, a) => f(...a)
|
|
1233
1471
|
}));
|
|
@@ -1236,28 +1474,44 @@ var WebsocketSignalManager = class {
|
|
|
1236
1474
|
async subscribeMessages(peerId) {
|
|
1237
1475
|
log5(`Subscribed for message stream peerId=${peerId}`, void 0, {
|
|
1238
1476
|
F: __dxlog_file5,
|
|
1239
|
-
L:
|
|
1477
|
+
L: 127,
|
|
1240
1478
|
S: this,
|
|
1241
1479
|
C: (f, a) => f(...a)
|
|
1242
1480
|
});
|
|
1243
|
-
invariant5(this._opened, "Closed"
|
|
1481
|
+
invariant5(this._opened, "Closed", {
|
|
1482
|
+
F: __dxlog_file5,
|
|
1483
|
+
L: 128,
|
|
1484
|
+
S: this,
|
|
1485
|
+
A: [
|
|
1486
|
+
"this._opened",
|
|
1487
|
+
"'Closed'"
|
|
1488
|
+
]
|
|
1489
|
+
});
|
|
1244
1490
|
await this._forEachServer(async (server) => server.subscribeMessages(peerId));
|
|
1245
1491
|
}
|
|
1246
1492
|
async unsubscribeMessages(peerId) {
|
|
1247
1493
|
log5(`Subscribed for message stream peerId=${peerId}`, void 0, {
|
|
1248
1494
|
F: __dxlog_file5,
|
|
1249
|
-
L:
|
|
1495
|
+
L: 134,
|
|
1250
1496
|
S: this,
|
|
1251
1497
|
C: (f, a) => f(...a)
|
|
1252
1498
|
});
|
|
1253
|
-
invariant5(this._opened, "Closed"
|
|
1499
|
+
invariant5(this._opened, "Closed", {
|
|
1500
|
+
F: __dxlog_file5,
|
|
1501
|
+
L: 135,
|
|
1502
|
+
S: this,
|
|
1503
|
+
A: [
|
|
1504
|
+
"this._opened",
|
|
1505
|
+
"'Closed'"
|
|
1506
|
+
]
|
|
1507
|
+
});
|
|
1254
1508
|
await this._forEachServer(async (server) => server.unsubscribeMessages(peerId));
|
|
1255
1509
|
}
|
|
1256
1510
|
_initContext() {
|
|
1257
1511
|
this._ctx = new Context4({
|
|
1258
1512
|
onError: (err) => log5.catch(err, void 0, {
|
|
1259
1513
|
F: __dxlog_file5,
|
|
1260
|
-
L:
|
|
1514
|
+
L: 142,
|
|
1261
1515
|
S: this,
|
|
1262
1516
|
C: (f, a) => f(...a)
|
|
1263
1517
|
})
|