@dxos/messaging 0.1.56-main.e47dfd1 → 0.1.56-main.e79d64a
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 +301 -123
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +301 -123
- 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.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 +1 -2
- package/src/signal-manager/websocket-signal-manager.ts +1 -2
package/dist/lib/node/index.cjs
CHANGED
|
@@ -39,9 +39,9 @@ __export(src_exports, {
|
|
|
39
39
|
module.exports = __toCommonJS(src_exports);
|
|
40
40
|
|
|
41
41
|
// packages/core/mesh/messaging/src/messenger.ts
|
|
42
|
-
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
43
42
|
var import_async = require("@dxos/async");
|
|
44
43
|
var import_context = require("@dxos/context");
|
|
44
|
+
var import_invariant = require("@dxos/invariant");
|
|
45
45
|
var import_keys = require("@dxos/keys");
|
|
46
46
|
var import_log = require("@dxos/log");
|
|
47
47
|
var import_protocols = require("@dxos/protocols");
|
|
@@ -76,14 +76,14 @@ var Messenger = class {
|
|
|
76
76
|
id: traceId
|
|
77
77
|
}), {
|
|
78
78
|
F: __dxlog_file,
|
|
79
|
-
L:
|
|
79
|
+
L: 62,
|
|
80
80
|
S: this,
|
|
81
81
|
C: (f, a) => f(...a)
|
|
82
82
|
});
|
|
83
83
|
this._ctx = new import_context.Context({
|
|
84
84
|
onError: (err) => import_log.log.catch(err, void 0, {
|
|
85
85
|
F: __dxlog_file,
|
|
86
|
-
L:
|
|
86
|
+
L: 64,
|
|
87
87
|
S: this,
|
|
88
88
|
C: (f, a) => f(...a)
|
|
89
89
|
})
|
|
@@ -93,7 +93,7 @@ var Messenger = class {
|
|
|
93
93
|
from: message.author
|
|
94
94
|
}, {
|
|
95
95
|
F: __dxlog_file,
|
|
96
|
-
L:
|
|
96
|
+
L: 68,
|
|
97
97
|
S: this,
|
|
98
98
|
C: (f, a) => f(...a)
|
|
99
99
|
});
|
|
@@ -104,7 +104,7 @@ var Messenger = class {
|
|
|
104
104
|
id: traceId
|
|
105
105
|
}), {
|
|
106
106
|
F: __dxlog_file,
|
|
107
|
-
L:
|
|
107
|
+
L: 73,
|
|
108
108
|
S: this,
|
|
109
109
|
C: (f, a) => f(...a)
|
|
110
110
|
});
|
|
@@ -117,20 +117,36 @@ var Messenger = class {
|
|
|
117
117
|
await this._ctx.dispose();
|
|
118
118
|
}
|
|
119
119
|
async sendMessage({ author, recipient, payload }) {
|
|
120
|
-
(0,
|
|
120
|
+
(0, import_invariant.invariant)(!this._closed, "Closed", {
|
|
121
|
+
F: __dxlog_file,
|
|
122
|
+
L: 85,
|
|
123
|
+
S: this,
|
|
124
|
+
A: [
|
|
125
|
+
"!this._closed",
|
|
126
|
+
"'Closed'"
|
|
127
|
+
]
|
|
128
|
+
});
|
|
121
129
|
const messageContext = this._ctx.derive();
|
|
122
130
|
const reliablePayload = {
|
|
123
131
|
messageId: import_keys.PublicKey.random(),
|
|
124
132
|
payload
|
|
125
133
|
};
|
|
126
|
-
(0,
|
|
134
|
+
(0, import_invariant.invariant)(!this._onAckCallbacks.has(reliablePayload.messageId), void 0, {
|
|
135
|
+
F: __dxlog_file,
|
|
136
|
+
L: 92,
|
|
137
|
+
S: this,
|
|
138
|
+
A: [
|
|
139
|
+
"!this._onAckCallbacks.has(reliablePayload.messageId!)",
|
|
140
|
+
""
|
|
141
|
+
]
|
|
142
|
+
});
|
|
127
143
|
(0, import_log.log)("send message", {
|
|
128
144
|
messageId: reliablePayload.messageId,
|
|
129
145
|
author,
|
|
130
146
|
recipient
|
|
131
147
|
}, {
|
|
132
148
|
F: __dxlog_file,
|
|
133
|
-
L:
|
|
149
|
+
L: 93,
|
|
134
150
|
S: this,
|
|
135
151
|
C: (f, a) => f(...a)
|
|
136
152
|
});
|
|
@@ -145,7 +161,7 @@ var Messenger = class {
|
|
|
145
161
|
messageId: reliablePayload.messageId
|
|
146
162
|
}, {
|
|
147
163
|
F: __dxlog_file,
|
|
148
|
-
L:
|
|
164
|
+
L: 107,
|
|
149
165
|
S: this,
|
|
150
166
|
C: (f, a) => f(...a)
|
|
151
167
|
});
|
|
@@ -157,7 +173,7 @@ var Messenger = class {
|
|
|
157
173
|
err
|
|
158
174
|
}, {
|
|
159
175
|
F: __dxlog_file,
|
|
160
|
-
L:
|
|
176
|
+
L: 109,
|
|
161
177
|
S: this,
|
|
162
178
|
C: (f, a) => f(...a)
|
|
163
179
|
}));
|
|
@@ -167,7 +183,7 @@ var Messenger = class {
|
|
|
167
183
|
messageId: reliablePayload.messageId
|
|
168
184
|
}, {
|
|
169
185
|
F: __dxlog_file,
|
|
170
|
-
L:
|
|
186
|
+
L: 118,
|
|
171
187
|
S: this,
|
|
172
188
|
C: (f, a) => f(...a)
|
|
173
189
|
});
|
|
@@ -192,7 +208,15 @@ var Messenger = class {
|
|
|
192
208
|
* @param payloadType if not specified, onMessage will be subscribed to all types of messages.
|
|
193
209
|
*/
|
|
194
210
|
async listen({ peerId, payloadType, onMessage }) {
|
|
195
|
-
(0,
|
|
211
|
+
(0, import_invariant.invariant)(!this._closed, "Closed", {
|
|
212
|
+
F: __dxlog_file,
|
|
213
|
+
L: 149,
|
|
214
|
+
S: this,
|
|
215
|
+
A: [
|
|
216
|
+
"!this._closed",
|
|
217
|
+
"'Closed'"
|
|
218
|
+
]
|
|
219
|
+
});
|
|
196
220
|
await this._signalManager.subscribeMessages(peerId);
|
|
197
221
|
let listeners;
|
|
198
222
|
if (!payloadType) {
|
|
@@ -248,7 +272,15 @@ var Messenger = class {
|
|
|
248
272
|
}
|
|
249
273
|
}
|
|
250
274
|
async _handleReliablePayload({ author, recipient, payload }) {
|
|
251
|
-
(0,
|
|
275
|
+
(0, import_invariant.invariant)(payload.type_url === "dxos.mesh.messaging.ReliablePayload", void 0, {
|
|
276
|
+
F: __dxlog_file,
|
|
277
|
+
L: 210,
|
|
278
|
+
S: this,
|
|
279
|
+
A: [
|
|
280
|
+
"payload.type_url === 'dxos.mesh.messaging.ReliablePayload'",
|
|
281
|
+
""
|
|
282
|
+
]
|
|
283
|
+
});
|
|
252
284
|
const reliablePayload = ReliablePayload.decode(payload.value, {
|
|
253
285
|
preserveAny: true
|
|
254
286
|
});
|
|
@@ -256,7 +288,7 @@ var Messenger = class {
|
|
|
256
288
|
messageId: reliablePayload.messageId
|
|
257
289
|
}, {
|
|
258
290
|
F: __dxlog_file,
|
|
259
|
-
L:
|
|
291
|
+
L: 213,
|
|
260
292
|
S: this,
|
|
261
293
|
C: (f, a) => f(...a)
|
|
262
294
|
});
|
|
@@ -276,9 +308,16 @@ var Messenger = class {
|
|
|
276
308
|
});
|
|
277
309
|
}
|
|
278
310
|
async _handleAcknowledgement({ payload }) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
311
|
+
(0, import_invariant.invariant)(payload.type_url === "dxos.mesh.messaging.Acknowledgement", void 0, {
|
|
312
|
+
F: __dxlog_file,
|
|
313
|
+
L: 235,
|
|
314
|
+
S: this,
|
|
315
|
+
A: [
|
|
316
|
+
"payload.type_url === 'dxos.mesh.messaging.Acknowledgement'",
|
|
317
|
+
""
|
|
318
|
+
]
|
|
319
|
+
});
|
|
320
|
+
this._onAckCallbacks.get(Acknowledgement.decode(payload.value).messageId)?.();
|
|
282
321
|
}
|
|
283
322
|
async _sendAcknowledgement({ author, recipient, messageId }) {
|
|
284
323
|
(0, import_log.log)("sending ACK", {
|
|
@@ -287,7 +326,7 @@ var Messenger = class {
|
|
|
287
326
|
to: author
|
|
288
327
|
}, {
|
|
289
328
|
F: __dxlog_file,
|
|
290
|
-
L:
|
|
329
|
+
L: 248,
|
|
291
330
|
S: this,
|
|
292
331
|
C: (f, a) => f(...a)
|
|
293
332
|
});
|
|
@@ -326,9 +365,9 @@ var Messenger = class {
|
|
|
326
365
|
};
|
|
327
366
|
|
|
328
367
|
// packages/core/mesh/messaging/src/signal-client/signal-client.ts
|
|
329
|
-
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
330
368
|
var import_async3 = require("@dxos/async");
|
|
331
369
|
var import_context2 = require("@dxos/context");
|
|
370
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
332
371
|
var import_keys3 = require("@dxos/keys");
|
|
333
372
|
var import_log3 = require("@dxos/log");
|
|
334
373
|
var import_protocols3 = require("@dxos/protocols");
|
|
@@ -337,8 +376,8 @@ var import_util2 = require("@dxos/util");
|
|
|
337
376
|
|
|
338
377
|
// packages/core/mesh/messaging/src/signal-client/signal-rpc-client.ts
|
|
339
378
|
var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
|
|
340
|
-
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
341
379
|
var import_async2 = require("@dxos/async");
|
|
380
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
342
381
|
var import_keys2 = require("@dxos/keys");
|
|
343
382
|
var import_log2 = require("@dxos/log");
|
|
344
383
|
var import_protocols2 = require("@dxos/protocols");
|
|
@@ -396,7 +435,6 @@ var SignalRPCClient = class {
|
|
|
396
435
|
}
|
|
397
436
|
});
|
|
398
437
|
this._socket.onopen = async () => {
|
|
399
|
-
var _a, _b, _c, _d;
|
|
400
438
|
try {
|
|
401
439
|
await this._rpc.open();
|
|
402
440
|
(0, import_log2.log)(`RPC open ${this._url}`, void 0, {
|
|
@@ -405,32 +443,30 @@ var SignalRPCClient = class {
|
|
|
405
443
|
S: this,
|
|
406
444
|
C: (f, a) => f(...a)
|
|
407
445
|
});
|
|
408
|
-
|
|
446
|
+
this._callbacks.onConnected?.();
|
|
409
447
|
this._connectTrigger.wake();
|
|
410
448
|
} catch (err) {
|
|
411
|
-
|
|
449
|
+
this._callbacks.onError?.(err);
|
|
412
450
|
}
|
|
413
451
|
};
|
|
414
452
|
this._socket.onclose = async () => {
|
|
415
|
-
var _a, _b;
|
|
416
453
|
(0, import_log2.log)(`Disconnected ${this._url}`, void 0, {
|
|
417
454
|
F: __dxlog_file2,
|
|
418
455
|
L: 98,
|
|
419
456
|
S: this,
|
|
420
457
|
C: (f, a) => f(...a)
|
|
421
458
|
});
|
|
422
|
-
|
|
459
|
+
this._callbacks.onDisconnected?.();
|
|
423
460
|
await this.close();
|
|
424
461
|
};
|
|
425
462
|
this._socket.onerror = async (event) => {
|
|
426
|
-
var _a, _b, _c, _d, _e;
|
|
427
463
|
if (this._closed) {
|
|
428
464
|
return;
|
|
429
465
|
}
|
|
430
|
-
|
|
466
|
+
this._callbacks.onError?.(event.error ?? new Error(event.message));
|
|
431
467
|
this._connectTrigger.reset();
|
|
432
468
|
try {
|
|
433
|
-
await
|
|
469
|
+
await this._rpc?.close();
|
|
434
470
|
} catch (err) {
|
|
435
471
|
import_log2.log.catch(err, void 0, {
|
|
436
472
|
F: __dxlog_file2,
|
|
@@ -440,7 +476,7 @@ var SignalRPCClient = class {
|
|
|
440
476
|
});
|
|
441
477
|
}
|
|
442
478
|
this._closed = true;
|
|
443
|
-
import_log2.log.warn(
|
|
479
|
+
import_log2.log.warn(event.message ?? "Socket error", {
|
|
444
480
|
url: this._url
|
|
445
481
|
}, {
|
|
446
482
|
F: __dxlog_file2,
|
|
@@ -459,11 +495,10 @@ var SignalRPCClient = class {
|
|
|
459
495
|
});
|
|
460
496
|
}
|
|
461
497
|
async close() {
|
|
462
|
-
var _a, _b;
|
|
463
498
|
this._closed = true;
|
|
464
499
|
try {
|
|
465
|
-
await
|
|
466
|
-
|
|
500
|
+
await this._rpc?.close();
|
|
501
|
+
this._socket?.close();
|
|
467
502
|
} catch (err) {
|
|
468
503
|
import_log2.log.warn("close error", err, {
|
|
469
504
|
F: __dxlog_file2,
|
|
@@ -484,8 +519,24 @@ var SignalRPCClient = class {
|
|
|
484
519
|
C: (f, a) => f(...a)
|
|
485
520
|
});
|
|
486
521
|
await this._connectTrigger.wait();
|
|
487
|
-
(0,
|
|
488
|
-
|
|
522
|
+
(0, import_invariant2.invariant)(!this._closed, "SignalRPCClient is closed", {
|
|
523
|
+
F: __dxlog_file2,
|
|
524
|
+
L: 138,
|
|
525
|
+
S: this,
|
|
526
|
+
A: [
|
|
527
|
+
"!this._closed",
|
|
528
|
+
"'SignalRPCClient is closed'"
|
|
529
|
+
]
|
|
530
|
+
});
|
|
531
|
+
(0, import_invariant2.invariant)(this._rpc, "Rpc is not initialized", {
|
|
532
|
+
F: __dxlog_file2,
|
|
533
|
+
L: 139,
|
|
534
|
+
S: this,
|
|
535
|
+
A: [
|
|
536
|
+
"this._rpc",
|
|
537
|
+
"'Rpc is not initialized'"
|
|
538
|
+
]
|
|
539
|
+
});
|
|
489
540
|
const swarmStream = this._rpc.rpc.Signal.join({
|
|
490
541
|
swarm: topic.asUint8Array(),
|
|
491
542
|
peer: peerId.asUint8Array()
|
|
@@ -502,9 +553,25 @@ var SignalRPCClient = class {
|
|
|
502
553
|
S: this,
|
|
503
554
|
C: (f, a) => f(...a)
|
|
504
555
|
});
|
|
505
|
-
(0,
|
|
556
|
+
(0, import_invariant2.invariant)(!this._closed, "SignalRPCClient is closed", {
|
|
557
|
+
F: __dxlog_file2,
|
|
558
|
+
L: 150,
|
|
559
|
+
S: this,
|
|
560
|
+
A: [
|
|
561
|
+
"!this._closed",
|
|
562
|
+
"'SignalRPCClient is closed'"
|
|
563
|
+
]
|
|
564
|
+
});
|
|
506
565
|
await this._connectTrigger.wait();
|
|
507
|
-
(0,
|
|
566
|
+
(0, import_invariant2.invariant)(this._rpc, "Rpc is not initialized", {
|
|
567
|
+
F: __dxlog_file2,
|
|
568
|
+
L: 152,
|
|
569
|
+
S: this,
|
|
570
|
+
A: [
|
|
571
|
+
"this._rpc",
|
|
572
|
+
"'Rpc is not initialized'"
|
|
573
|
+
]
|
|
574
|
+
});
|
|
508
575
|
const messageStream = this._rpc.rpc.Signal.receiveMessages({
|
|
509
576
|
peer: peerId.asUint8Array()
|
|
510
577
|
});
|
|
@@ -522,9 +589,25 @@ var SignalRPCClient = class {
|
|
|
522
589
|
S: this,
|
|
523
590
|
C: (f, a) => f(...a)
|
|
524
591
|
});
|
|
525
|
-
(0,
|
|
592
|
+
(0, import_invariant2.invariant)(!this._closed, "SignalRPCClient is closed", {
|
|
593
|
+
F: __dxlog_file2,
|
|
594
|
+
L: 162,
|
|
595
|
+
S: this,
|
|
596
|
+
A: [
|
|
597
|
+
"!this._closed",
|
|
598
|
+
"'SignalRPCClient is closed'"
|
|
599
|
+
]
|
|
600
|
+
});
|
|
526
601
|
await this._connectTrigger.wait();
|
|
527
|
-
(0,
|
|
602
|
+
(0, import_invariant2.invariant)(this._rpc, "Rpc is not initialized", {
|
|
603
|
+
F: __dxlog_file2,
|
|
604
|
+
L: 164,
|
|
605
|
+
S: this,
|
|
606
|
+
A: [
|
|
607
|
+
"this._rpc",
|
|
608
|
+
"'Rpc is not initialized'"
|
|
609
|
+
]
|
|
610
|
+
});
|
|
528
611
|
await this._rpc.rpc.Signal.sendMessage({
|
|
529
612
|
author: author.asUint8Array(),
|
|
530
613
|
recipient: recipient.asUint8Array(),
|
|
@@ -550,8 +633,8 @@ var SignalClient = class {
|
|
|
550
633
|
this._onSwarmEvent = _onSwarmEvent;
|
|
551
634
|
this._state = import_signal.SignalState.CLOSED;
|
|
552
635
|
this._reconnectAfter = DEFAULT_RECONNECT_TIMEOUT;
|
|
553
|
-
this._connectionStarted = new Date();
|
|
554
|
-
this._lastStateChange = new Date();
|
|
636
|
+
this._connectionStarted = /* @__PURE__ */ new Date();
|
|
637
|
+
this._lastStateChange = /* @__PURE__ */ new Date();
|
|
555
638
|
this._clientReady = new import_async3.Trigger();
|
|
556
639
|
this.statusChanged = new import_async3.Event();
|
|
557
640
|
this.commandTrace = new import_async3.Event();
|
|
@@ -577,7 +660,7 @@ var SignalClient = class {
|
|
|
577
660
|
id: this._instanceId
|
|
578
661
|
}), {
|
|
579
662
|
F: __dxlog_file3,
|
|
580
|
-
L:
|
|
663
|
+
L: 135,
|
|
581
664
|
S: this,
|
|
582
665
|
C: (f, a) => f(...a)
|
|
583
666
|
});
|
|
@@ -589,14 +672,13 @@ var SignalClient = class {
|
|
|
589
672
|
}
|
|
590
673
|
this._ctx = new import_context2.Context({
|
|
591
674
|
onError: (err) => {
|
|
592
|
-
|
|
593
|
-
if (this._state === import_signal.SignalState.CLOSED || ((_a = this._ctx) == null ? void 0 : _a.disposed)) {
|
|
675
|
+
if (this._state === import_signal.SignalState.CLOSED || this._ctx?.disposed) {
|
|
594
676
|
return;
|
|
595
677
|
}
|
|
596
678
|
if (this._state === import_signal.SignalState.CONNECTED) {
|
|
597
679
|
import_log3.log.warn("SignalClient error:", err, {
|
|
598
680
|
F: __dxlog_file3,
|
|
599
|
-
L:
|
|
681
|
+
L: 147,
|
|
600
682
|
S: this,
|
|
601
683
|
C: (f, a) => f(...a)
|
|
602
684
|
});
|
|
@@ -623,16 +705,15 @@ var SignalClient = class {
|
|
|
623
705
|
id: this._instanceId
|
|
624
706
|
}), {
|
|
625
707
|
F: __dxlog_file3,
|
|
626
|
-
L:
|
|
708
|
+
L: 176,
|
|
627
709
|
S: this,
|
|
628
710
|
C: (f, a) => f(...a)
|
|
629
711
|
});
|
|
630
712
|
}
|
|
631
713
|
async close() {
|
|
632
|
-
var _a, _b;
|
|
633
714
|
(0, import_log3.log)("closing...", void 0, {
|
|
634
715
|
F: __dxlog_file3,
|
|
635
|
-
L:
|
|
716
|
+
L: 180,
|
|
636
717
|
S: this,
|
|
637
718
|
C: (f, a) => f(...a)
|
|
638
719
|
});
|
|
@@ -641,24 +722,23 @@ var SignalClient = class {
|
|
|
641
722
|
].includes(this._state)) {
|
|
642
723
|
return;
|
|
643
724
|
}
|
|
644
|
-
await
|
|
725
|
+
await this._ctx?.dispose();
|
|
645
726
|
this._clientReady.reset();
|
|
646
|
-
await
|
|
727
|
+
await this._client?.close();
|
|
647
728
|
this._client = void 0;
|
|
648
729
|
this._setState(import_signal.SignalState.CLOSED);
|
|
649
730
|
(0, import_log3.log)("closed", void 0, {
|
|
650
731
|
F: __dxlog_file3,
|
|
651
|
-
L:
|
|
732
|
+
L: 191,
|
|
652
733
|
S: this,
|
|
653
734
|
C: (f, a) => f(...a)
|
|
654
735
|
});
|
|
655
736
|
}
|
|
656
737
|
getStatus() {
|
|
657
|
-
var _a;
|
|
658
738
|
return {
|
|
659
739
|
host: this._host,
|
|
660
740
|
state: this._state,
|
|
661
|
-
error:
|
|
741
|
+
error: this._lastError?.message,
|
|
662
742
|
reconnectIn: this._reconnectAfter,
|
|
663
743
|
connectionStarted: this._connectionStarted,
|
|
664
744
|
lastStateChange: this._lastStateChange
|
|
@@ -670,7 +750,7 @@ var SignalClient = class {
|
|
|
670
750
|
peerId
|
|
671
751
|
}, {
|
|
672
752
|
F: __dxlog_file3,
|
|
673
|
-
L:
|
|
753
|
+
L: 206,
|
|
674
754
|
S: this,
|
|
675
755
|
C: (f, a) => f(...a)
|
|
676
756
|
});
|
|
@@ -682,21 +762,20 @@ var SignalClient = class {
|
|
|
682
762
|
this._reconcileTask.schedule();
|
|
683
763
|
}
|
|
684
764
|
async leave({ topic, peerId }) {
|
|
685
|
-
var _a;
|
|
686
765
|
this._performance.leaveCounter++;
|
|
687
766
|
(0, import_log3.log)("leaving", {
|
|
688
767
|
topic,
|
|
689
768
|
peerId
|
|
690
769
|
}, {
|
|
691
770
|
F: __dxlog_file3,
|
|
692
|
-
L:
|
|
771
|
+
L: 214,
|
|
693
772
|
S: this,
|
|
694
773
|
C: (f, a) => f(...a)
|
|
695
774
|
});
|
|
696
|
-
|
|
775
|
+
this._swarmStreams.get({
|
|
697
776
|
topic,
|
|
698
777
|
peerId
|
|
699
|
-
})
|
|
778
|
+
})?.close();
|
|
700
779
|
this._swarmStreams.delete({
|
|
701
780
|
topic,
|
|
702
781
|
peerId
|
|
@@ -709,7 +788,15 @@ var SignalClient = class {
|
|
|
709
788
|
async sendMessage(msg) {
|
|
710
789
|
this._performance.sentMessages++;
|
|
711
790
|
await this._clientReady.wait();
|
|
712
|
-
(0,
|
|
791
|
+
(0, import_invariant3.invariant)(this._state === import_signal.SignalState.CONNECTED, "Not connected to Signal Server", {
|
|
792
|
+
F: __dxlog_file3,
|
|
793
|
+
L: 224,
|
|
794
|
+
S: this,
|
|
795
|
+
A: [
|
|
796
|
+
"this._state === SignalState.CONNECTED",
|
|
797
|
+
"'Not connected to Signal Server'"
|
|
798
|
+
]
|
|
799
|
+
});
|
|
713
800
|
await this._client.sendMessage(msg);
|
|
714
801
|
}
|
|
715
802
|
async subscribeMessages(peerId) {
|
|
@@ -717,7 +804,7 @@ var SignalClient = class {
|
|
|
717
804
|
peerId
|
|
718
805
|
}, {
|
|
719
806
|
F: __dxlog_file3,
|
|
720
|
-
L:
|
|
807
|
+
L: 229,
|
|
721
808
|
S: this,
|
|
722
809
|
C: (f, a) => f(...a)
|
|
723
810
|
});
|
|
@@ -727,19 +814,18 @@ var SignalClient = class {
|
|
|
727
814
|
this._reconcileTask.schedule();
|
|
728
815
|
}
|
|
729
816
|
async unsubscribeMessages(peerId) {
|
|
730
|
-
var _a;
|
|
731
817
|
(0, import_log3.log)("unsubscribing from messages", {
|
|
732
818
|
peerId
|
|
733
819
|
}, {
|
|
734
820
|
F: __dxlog_file3,
|
|
735
|
-
L:
|
|
821
|
+
L: 235,
|
|
736
822
|
S: this,
|
|
737
823
|
C: (f, a) => f(...a)
|
|
738
824
|
});
|
|
739
825
|
this._subscribedMessages.delete({
|
|
740
826
|
peerId
|
|
741
827
|
});
|
|
742
|
-
|
|
828
|
+
this._messageStreams.get(peerId)?.close();
|
|
743
829
|
this._messageStreams.delete(peerId);
|
|
744
830
|
}
|
|
745
831
|
_scheduleReconcileAfterError() {
|
|
@@ -749,12 +835,12 @@ var SignalClient = class {
|
|
|
749
835
|
}
|
|
750
836
|
_setState(newState) {
|
|
751
837
|
this._state = newState;
|
|
752
|
-
this._lastStateChange = new Date();
|
|
838
|
+
this._lastStateChange = /* @__PURE__ */ new Date();
|
|
753
839
|
(0, import_log3.log)("signal state changed", {
|
|
754
840
|
status: this.getStatus()
|
|
755
841
|
}, {
|
|
756
842
|
F: __dxlog_file3,
|
|
757
|
-
L:
|
|
843
|
+
L: 254,
|
|
758
844
|
S: this,
|
|
759
845
|
C: (f, a) => f(...a)
|
|
760
846
|
});
|
|
@@ -766,22 +852,30 @@ var SignalClient = class {
|
|
|
766
852
|
state: this._state
|
|
767
853
|
}, {
|
|
768
854
|
F: __dxlog_file3,
|
|
769
|
-
L:
|
|
855
|
+
L: 259,
|
|
770
856
|
S: this,
|
|
771
857
|
C: (f, a) => f(...a)
|
|
772
858
|
});
|
|
773
|
-
(0,
|
|
774
|
-
|
|
859
|
+
(0, import_invariant3.invariant)(!this._client, "Client already created", {
|
|
860
|
+
F: __dxlog_file3,
|
|
861
|
+
L: 260,
|
|
862
|
+
S: this,
|
|
863
|
+
A: [
|
|
864
|
+
"!this._client",
|
|
865
|
+
"'Client already created'"
|
|
866
|
+
]
|
|
867
|
+
});
|
|
868
|
+
this._connectionStarted = /* @__PURE__ */ new Date();
|
|
775
869
|
this._connectionCtx = this._ctx.derive();
|
|
776
|
-
this._connectionCtx.onDispose(() => {
|
|
870
|
+
this._connectionCtx.onDispose(async () => {
|
|
777
871
|
(0, import_log3.log)("connection context disposed", void 0, {
|
|
778
872
|
F: __dxlog_file3,
|
|
779
|
-
L:
|
|
873
|
+
L: 267,
|
|
780
874
|
S: this,
|
|
781
875
|
C: (f, a) => f(...a)
|
|
782
876
|
});
|
|
783
|
-
Array.from(this._swarmStreams.values()).
|
|
784
|
-
Array.from(this._messageStreams.values()).
|
|
877
|
+
await Promise.all(Array.from(this._swarmStreams.values()).map((stream) => stream.close()));
|
|
878
|
+
await Promise.all(Array.from(this._messageStreams.values()).map((stream) => stream.close()));
|
|
785
879
|
this._swarmStreams.clear();
|
|
786
880
|
this._messageStreams.clear();
|
|
787
881
|
});
|
|
@@ -792,7 +886,7 @@ var SignalClient = class {
|
|
|
792
886
|
onConnected: () => {
|
|
793
887
|
(0, import_log3.log)("socket connected", void 0, {
|
|
794
888
|
F: __dxlog_file3,
|
|
795
|
-
L:
|
|
889
|
+
L: 279,
|
|
796
890
|
S: this,
|
|
797
891
|
C: (f, a) => f(...a)
|
|
798
892
|
});
|
|
@@ -807,7 +901,7 @@ var SignalClient = class {
|
|
|
807
901
|
state: this._state
|
|
808
902
|
}, {
|
|
809
903
|
F: __dxlog_file3,
|
|
810
|
-
L:
|
|
904
|
+
L: 288,
|
|
811
905
|
S: this,
|
|
812
906
|
C: (f, a) => f(...a)
|
|
813
907
|
});
|
|
@@ -827,7 +921,7 @@ var SignalClient = class {
|
|
|
827
921
|
state: this._state
|
|
828
922
|
}, {
|
|
829
923
|
F: __dxlog_file3,
|
|
830
|
-
L:
|
|
924
|
+
L: 303,
|
|
831
925
|
S: this,
|
|
832
926
|
C: (f, a) => f(...a)
|
|
833
927
|
});
|
|
@@ -854,12 +948,11 @@ var SignalClient = class {
|
|
|
854
948
|
this._reconnectAfter = Math.min(this._reconnectAfter, MAX_RECONNECT_TIMEOUT);
|
|
855
949
|
}
|
|
856
950
|
async _reconnect() {
|
|
857
|
-
var _a, _b;
|
|
858
951
|
(0, import_log3.log)(`reconnecting in ${this._reconnectAfter}ms`, {
|
|
859
952
|
state: this._state
|
|
860
953
|
}, {
|
|
861
954
|
F: __dxlog_file3,
|
|
862
|
-
L:
|
|
955
|
+
L: 330,
|
|
863
956
|
S: this,
|
|
864
957
|
C: (f, a) => f(...a)
|
|
865
958
|
});
|
|
@@ -867,7 +960,7 @@ var SignalClient = class {
|
|
|
867
960
|
if (this._state === import_signal.SignalState.RECONNECTING) {
|
|
868
961
|
import_log3.log.warn("Signal api already reconnecting.", void 0, {
|
|
869
962
|
F: __dxlog_file3,
|
|
870
|
-
L:
|
|
963
|
+
L: 334,
|
|
871
964
|
S: this,
|
|
872
965
|
C: (f, a) => f(...a)
|
|
873
966
|
});
|
|
@@ -877,8 +970,8 @@ var SignalClient = class {
|
|
|
877
970
|
return;
|
|
878
971
|
}
|
|
879
972
|
this._clientReady.reset();
|
|
880
|
-
await
|
|
881
|
-
|
|
973
|
+
await this._connectionCtx?.dispose();
|
|
974
|
+
this._client?.close().catch(() => {
|
|
882
975
|
});
|
|
883
976
|
this._client = void 0;
|
|
884
977
|
await (0, import_context2.cancelWithContext)(this._ctx, (0, import_async3.sleep)(this._reconnectAfter));
|
|
@@ -886,10 +979,17 @@ var SignalClient = class {
|
|
|
886
979
|
this._createClient();
|
|
887
980
|
}
|
|
888
981
|
async _reconcileSwarmSubscriptions() {
|
|
889
|
-
var _a;
|
|
890
982
|
await (0, import_async3.asyncTimeout)((0, import_context2.cancelWithContext)(this._connectionCtx, this._clientReady.wait()), 5e3);
|
|
891
983
|
const client = this._client;
|
|
892
|
-
(0,
|
|
984
|
+
(0, import_invariant3.invariant)(this._state === import_signal.SignalState.CONNECTED, "Not connected to Signal Server", {
|
|
985
|
+
F: __dxlog_file3,
|
|
986
|
+
L: 359,
|
|
987
|
+
S: this,
|
|
988
|
+
A: [
|
|
989
|
+
"this._state === SignalState.CONNECTED",
|
|
990
|
+
"'Not connected to Signal Server'"
|
|
991
|
+
]
|
|
992
|
+
});
|
|
893
993
|
for (const { topic, peerId } of this._swarmStreams.keys()) {
|
|
894
994
|
if (this._joinedTopics.has({
|
|
895
995
|
topic,
|
|
@@ -897,10 +997,10 @@ var SignalClient = class {
|
|
|
897
997
|
})) {
|
|
898
998
|
continue;
|
|
899
999
|
}
|
|
900
|
-
|
|
1000
|
+
this._swarmStreams.get({
|
|
901
1001
|
topic,
|
|
902
1002
|
peerId
|
|
903
|
-
})
|
|
1003
|
+
})?.close();
|
|
904
1004
|
this._swarmStreams.delete({
|
|
905
1005
|
topic,
|
|
906
1006
|
peerId
|
|
@@ -922,7 +1022,7 @@ var SignalClient = class {
|
|
|
922
1022
|
swarmEvent
|
|
923
1023
|
}, {
|
|
924
1024
|
F: __dxlog_file3,
|
|
925
|
-
L:
|
|
1025
|
+
L: 386,
|
|
926
1026
|
S: this,
|
|
927
1027
|
C: (f, a) => f(...a)
|
|
928
1028
|
});
|
|
@@ -938,17 +1038,24 @@ var SignalClient = class {
|
|
|
938
1038
|
}
|
|
939
1039
|
}
|
|
940
1040
|
async _reconcileMessageSubscriptions() {
|
|
941
|
-
var _a;
|
|
942
1041
|
await (0, import_async3.asyncTimeout)((0, import_context2.cancelWithContext)(this._connectionCtx, this._clientReady.wait()), 5e3);
|
|
943
1042
|
const client = this._client;
|
|
944
|
-
(0,
|
|
1043
|
+
(0, import_invariant3.invariant)(this._state === import_signal.SignalState.CONNECTED, "Not connected to Signal Server", {
|
|
1044
|
+
F: __dxlog_file3,
|
|
1045
|
+
L: 399,
|
|
1046
|
+
S: this,
|
|
1047
|
+
A: [
|
|
1048
|
+
"this._state === SignalState.CONNECTED",
|
|
1049
|
+
"'Not connected to Signal Server'"
|
|
1050
|
+
]
|
|
1051
|
+
});
|
|
945
1052
|
for (const peerId of this._messageStreams.keys()) {
|
|
946
1053
|
if (this._subscribedMessages.has({
|
|
947
1054
|
peerId
|
|
948
1055
|
})) {
|
|
949
1056
|
continue;
|
|
950
1057
|
}
|
|
951
|
-
|
|
1058
|
+
this._messageStreams.get(peerId)?.close();
|
|
952
1059
|
this._messageStreams.delete(peerId);
|
|
953
1060
|
}
|
|
954
1061
|
for (const { peerId } of this._subscribedMessages.values()) {
|
|
@@ -970,9 +1077,9 @@ var SignalClient = class {
|
|
|
970
1077
|
};
|
|
971
1078
|
|
|
972
1079
|
// packages/core/mesh/messaging/src/signal-manager/memory-signal-manager.ts
|
|
973
|
-
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
974
1080
|
var import_async4 = require("@dxos/async");
|
|
975
1081
|
var import_context3 = require("@dxos/context");
|
|
1082
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
976
1083
|
var import_keys4 = require("@dxos/keys");
|
|
977
1084
|
var import_log4 = require("@dxos/log");
|
|
978
1085
|
var import_protocols4 = require("@dxos/protocols");
|
|
@@ -1028,7 +1135,15 @@ var MemorySignalManager = class {
|
|
|
1028
1135
|
return [];
|
|
1029
1136
|
}
|
|
1030
1137
|
async join({ topic, peerId }) {
|
|
1031
|
-
(0,
|
|
1138
|
+
(0, import_invariant4.invariant)(!this._ctx.disposed, "Closed", {
|
|
1139
|
+
F: __dxlog_file4,
|
|
1140
|
+
L: 104,
|
|
1141
|
+
S: this,
|
|
1142
|
+
A: [
|
|
1143
|
+
"!this._ctx.disposed",
|
|
1144
|
+
"'Closed'"
|
|
1145
|
+
]
|
|
1146
|
+
});
|
|
1032
1147
|
this._joinedSwarms.add({
|
|
1033
1148
|
topic,
|
|
1034
1149
|
peerId
|
|
@@ -1042,7 +1157,7 @@ var MemorySignalManager = class {
|
|
|
1042
1157
|
swarmEvent: {
|
|
1043
1158
|
peerAvailable: {
|
|
1044
1159
|
peer: peerId.asUint8Array(),
|
|
1045
|
-
since: new Date()
|
|
1160
|
+
since: /* @__PURE__ */ new Date()
|
|
1046
1161
|
}
|
|
1047
1162
|
}
|
|
1048
1163
|
});
|
|
@@ -1053,7 +1168,7 @@ var MemorySignalManager = class {
|
|
|
1053
1168
|
swarmEvent: {
|
|
1054
1169
|
peerAvailable: {
|
|
1055
1170
|
peer: peerId2.asUint8Array(),
|
|
1056
|
-
since: new Date()
|
|
1171
|
+
since: /* @__PURE__ */ new Date()
|
|
1057
1172
|
}
|
|
1058
1173
|
}
|
|
1059
1174
|
});
|
|
@@ -1061,7 +1176,15 @@ var MemorySignalManager = class {
|
|
|
1061
1176
|
}
|
|
1062
1177
|
}
|
|
1063
1178
|
async leave({ topic, peerId }) {
|
|
1064
|
-
(0,
|
|
1179
|
+
(0, import_invariant4.invariant)(!this._ctx.disposed, "Closed", {
|
|
1180
|
+
F: __dxlog_file4,
|
|
1181
|
+
L: 140,
|
|
1182
|
+
S: this,
|
|
1183
|
+
A: [
|
|
1184
|
+
"!this._ctx.disposed",
|
|
1185
|
+
"'Closed'"
|
|
1186
|
+
]
|
|
1187
|
+
});
|
|
1065
1188
|
this._joinedSwarms.delete({
|
|
1066
1189
|
topic,
|
|
1067
1190
|
peerId
|
|
@@ -1087,12 +1210,28 @@ var MemorySignalManager = class {
|
|
|
1087
1210
|
...dec(payload)
|
|
1088
1211
|
}, {
|
|
1089
1212
|
F: __dxlog_file4,
|
|
1090
|
-
L:
|
|
1213
|
+
L: 160,
|
|
1091
1214
|
S: this,
|
|
1092
1215
|
C: (f, a) => f(...a)
|
|
1093
1216
|
});
|
|
1094
|
-
(0,
|
|
1095
|
-
|
|
1217
|
+
(0, import_invariant4.invariant)(recipient, void 0, {
|
|
1218
|
+
F: __dxlog_file4,
|
|
1219
|
+
L: 162,
|
|
1220
|
+
S: this,
|
|
1221
|
+
A: [
|
|
1222
|
+
"recipient",
|
|
1223
|
+
""
|
|
1224
|
+
]
|
|
1225
|
+
});
|
|
1226
|
+
(0, import_invariant4.invariant)(!this._ctx.disposed, "Closed", {
|
|
1227
|
+
F: __dxlog_file4,
|
|
1228
|
+
L: 163,
|
|
1229
|
+
S: this,
|
|
1230
|
+
A: [
|
|
1231
|
+
"!this._ctx.disposed",
|
|
1232
|
+
"'Closed'"
|
|
1233
|
+
]
|
|
1234
|
+
});
|
|
1096
1235
|
await this._freezeTrigger.wait();
|
|
1097
1236
|
const remote = this._context.connections.get(recipient);
|
|
1098
1237
|
if (!remote) {
|
|
@@ -1101,7 +1240,7 @@ var MemorySignalManager = class {
|
|
|
1101
1240
|
recipient
|
|
1102
1241
|
}, {
|
|
1103
1242
|
F: __dxlog_file4,
|
|
1104
|
-
L:
|
|
1243
|
+
L: 169,
|
|
1105
1244
|
S: this,
|
|
1106
1245
|
C: (f, a) => f(...a)
|
|
1107
1246
|
});
|
|
@@ -1113,7 +1252,7 @@ var MemorySignalManager = class {
|
|
|
1113
1252
|
recipient
|
|
1114
1253
|
}, {
|
|
1115
1254
|
F: __dxlog_file4,
|
|
1116
|
-
L:
|
|
1255
|
+
L: 174,
|
|
1117
1256
|
S: this,
|
|
1118
1257
|
C: (f, a) => f(...a)
|
|
1119
1258
|
});
|
|
@@ -1126,7 +1265,7 @@ var MemorySignalManager = class {
|
|
|
1126
1265
|
recipient
|
|
1127
1266
|
}, {
|
|
1128
1267
|
F: __dxlog_file4,
|
|
1129
|
-
L:
|
|
1268
|
+
L: 182,
|
|
1130
1269
|
S: this,
|
|
1131
1270
|
C: (f, a) => f(...a)
|
|
1132
1271
|
});
|
|
@@ -1138,7 +1277,7 @@ var MemorySignalManager = class {
|
|
|
1138
1277
|
...dec(payload)
|
|
1139
1278
|
}, {
|
|
1140
1279
|
F: __dxlog_file4,
|
|
1141
|
-
L:
|
|
1280
|
+
L: 186,
|
|
1142
1281
|
S: this,
|
|
1143
1282
|
C: (f, a) => f(...a)
|
|
1144
1283
|
});
|
|
@@ -1152,7 +1291,7 @@ var MemorySignalManager = class {
|
|
|
1152
1291
|
err
|
|
1153
1292
|
}, {
|
|
1154
1293
|
F: __dxlog_file4,
|
|
1155
|
-
L:
|
|
1294
|
+
L: 191,
|
|
1156
1295
|
S: this,
|
|
1157
1296
|
C: (f, a) => f(...a)
|
|
1158
1297
|
});
|
|
@@ -1163,7 +1302,7 @@ var MemorySignalManager = class {
|
|
|
1163
1302
|
peerId
|
|
1164
1303
|
}, {
|
|
1165
1304
|
F: __dxlog_file4,
|
|
1166
|
-
L:
|
|
1305
|
+
L: 196,
|
|
1167
1306
|
S: this,
|
|
1168
1307
|
C: (f, a) => f(...a)
|
|
1169
1308
|
});
|
|
@@ -1174,7 +1313,7 @@ var MemorySignalManager = class {
|
|
|
1174
1313
|
peerId
|
|
1175
1314
|
}, {
|
|
1176
1315
|
F: __dxlog_file4,
|
|
1177
|
-
L:
|
|
1316
|
+
L: 201,
|
|
1178
1317
|
S: this,
|
|
1179
1318
|
C: (f, a) => f(...a)
|
|
1180
1319
|
});
|
|
@@ -1188,24 +1327,23 @@ var MemorySignalManager = class {
|
|
|
1188
1327
|
}
|
|
1189
1328
|
};
|
|
1190
1329
|
var dec = (payload) => {
|
|
1191
|
-
var _a, _b, _c;
|
|
1192
1330
|
if (!payload.type_url.endsWith("ReliablePayload")) {
|
|
1193
1331
|
return {};
|
|
1194
1332
|
}
|
|
1195
1333
|
const relPayload = import_protocols4.schema.getCodecForType("dxos.mesh.messaging.ReliablePayload").decode(payload.value);
|
|
1196
|
-
if (typeof
|
|
1334
|
+
if (typeof relPayload?.payload?.data === "object") {
|
|
1197
1335
|
return {
|
|
1198
|
-
payload: Object.keys(
|
|
1199
|
-
sessionId:
|
|
1336
|
+
payload: Object.keys(relPayload?.payload?.data)[0],
|
|
1337
|
+
sessionId: relPayload?.payload?.sessionId
|
|
1200
1338
|
};
|
|
1201
1339
|
}
|
|
1202
1340
|
return {};
|
|
1203
1341
|
};
|
|
1204
1342
|
|
|
1205
1343
|
// packages/core/mesh/messaging/src/signal-manager/websocket-signal-manager.ts
|
|
1206
|
-
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
1207
1344
|
var import_async5 = require("@dxos/async");
|
|
1208
1345
|
var import_context4 = require("@dxos/context");
|
|
1346
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
1209
1347
|
var import_keys5 = require("@dxos/keys");
|
|
1210
1348
|
var import_log5 = require("@dxos/log");
|
|
1211
1349
|
var import_protocols5 = require("@dxos/protocols");
|
|
@@ -1235,7 +1373,7 @@ var WebsocketSignalManager = class {
|
|
|
1235
1373
|
hosts: this._hosts
|
|
1236
1374
|
}, {
|
|
1237
1375
|
F: __dxlog_file5,
|
|
1238
|
-
L:
|
|
1376
|
+
L: 46,
|
|
1239
1377
|
S: this,
|
|
1240
1378
|
C: (f, a) => f(...a)
|
|
1241
1379
|
});
|
|
@@ -1257,7 +1395,7 @@ var WebsocketSignalManager = class {
|
|
|
1257
1395
|
hosts: this._hosts
|
|
1258
1396
|
}, {
|
|
1259
1397
|
F: __dxlog_file5,
|
|
1260
|
-
L:
|
|
1398
|
+
L: 68,
|
|
1261
1399
|
S: this,
|
|
1262
1400
|
C: (f, a) => f(...a)
|
|
1263
1401
|
});
|
|
@@ -1265,7 +1403,7 @@ var WebsocketSignalManager = class {
|
|
|
1265
1403
|
id: this._instanceId
|
|
1266
1404
|
}), {
|
|
1267
1405
|
F: __dxlog_file5,
|
|
1268
|
-
L:
|
|
1406
|
+
L: 69,
|
|
1269
1407
|
S: this,
|
|
1270
1408
|
C: (f, a) => f(...a)
|
|
1271
1409
|
});
|
|
@@ -1278,7 +1416,7 @@ var WebsocketSignalManager = class {
|
|
|
1278
1416
|
id: this._instanceId
|
|
1279
1417
|
}), {
|
|
1280
1418
|
F: __dxlog_file5,
|
|
1281
|
-
L:
|
|
1419
|
+
L: 76,
|
|
1282
1420
|
S: this,
|
|
1283
1421
|
C: (f, a) => f(...a)
|
|
1284
1422
|
});
|
|
@@ -1300,11 +1438,19 @@ var WebsocketSignalManager = class {
|
|
|
1300
1438
|
peerId
|
|
1301
1439
|
}, {
|
|
1302
1440
|
F: __dxlog_file5,
|
|
1303
|
-
L:
|
|
1441
|
+
L: 96,
|
|
1304
1442
|
S: this,
|
|
1305
1443
|
C: (f, a) => f(...a)
|
|
1306
1444
|
});
|
|
1307
|
-
(0,
|
|
1445
|
+
(0, import_invariant5.invariant)(this._opened, "Closed", {
|
|
1446
|
+
F: __dxlog_file5,
|
|
1447
|
+
L: 97,
|
|
1448
|
+
S: this,
|
|
1449
|
+
A: [
|
|
1450
|
+
"this._opened",
|
|
1451
|
+
"'Closed'"
|
|
1452
|
+
]
|
|
1453
|
+
});
|
|
1308
1454
|
await this._forEachServer((server) => server.join({
|
|
1309
1455
|
topic,
|
|
1310
1456
|
peerId
|
|
@@ -1316,11 +1462,19 @@ var WebsocketSignalManager = class {
|
|
|
1316
1462
|
peerId
|
|
1317
1463
|
}, {
|
|
1318
1464
|
F: __dxlog_file5,
|
|
1319
|
-
L:
|
|
1465
|
+
L: 103,
|
|
1320
1466
|
S: this,
|
|
1321
1467
|
C: (f, a) => f(...a)
|
|
1322
1468
|
});
|
|
1323
|
-
(0,
|
|
1469
|
+
(0, import_invariant5.invariant)(this._opened, "Closed", {
|
|
1470
|
+
F: __dxlog_file5,
|
|
1471
|
+
L: 104,
|
|
1472
|
+
S: this,
|
|
1473
|
+
A: [
|
|
1474
|
+
"this._opened",
|
|
1475
|
+
"'Closed'"
|
|
1476
|
+
]
|
|
1477
|
+
});
|
|
1324
1478
|
await this._forEachServer((server) => server.leave({
|
|
1325
1479
|
topic,
|
|
1326
1480
|
peerId
|
|
@@ -1329,11 +1483,19 @@ var WebsocketSignalManager = class {
|
|
|
1329
1483
|
async sendMessage({ author, recipient, payload }) {
|
|
1330
1484
|
(0, import_log5.log)(`Signal ${recipient}`, void 0, {
|
|
1331
1485
|
F: __dxlog_file5,
|
|
1332
|
-
L:
|
|
1486
|
+
L: 118,
|
|
1333
1487
|
S: this,
|
|
1334
1488
|
C: (f, a) => f(...a)
|
|
1335
1489
|
});
|
|
1336
|
-
(0,
|
|
1490
|
+
(0, import_invariant5.invariant)(this._opened, "Closed", {
|
|
1491
|
+
F: __dxlog_file5,
|
|
1492
|
+
L: 119,
|
|
1493
|
+
S: this,
|
|
1494
|
+
A: [
|
|
1495
|
+
"this._opened",
|
|
1496
|
+
"'Closed'"
|
|
1497
|
+
]
|
|
1498
|
+
});
|
|
1337
1499
|
void this._forEachServer(async (server) => {
|
|
1338
1500
|
void server.sendMessage({
|
|
1339
1501
|
author,
|
|
@@ -1341,7 +1503,7 @@ var WebsocketSignalManager = class {
|
|
|
1341
1503
|
payload
|
|
1342
1504
|
}).catch((err) => (0, import_log5.log)(err, void 0, {
|
|
1343
1505
|
F: __dxlog_file5,
|
|
1344
|
-
L:
|
|
1506
|
+
L: 122,
|
|
1345
1507
|
S: this,
|
|
1346
1508
|
C: (f, a) => f(...a)
|
|
1347
1509
|
}));
|
|
@@ -1350,28 +1512,44 @@ var WebsocketSignalManager = class {
|
|
|
1350
1512
|
async subscribeMessages(peerId) {
|
|
1351
1513
|
(0, import_log5.log)(`Subscribed for message stream peerId=${peerId}`, void 0, {
|
|
1352
1514
|
F: __dxlog_file5,
|
|
1353
|
-
L:
|
|
1515
|
+
L: 127,
|
|
1354
1516
|
S: this,
|
|
1355
1517
|
C: (f, a) => f(...a)
|
|
1356
1518
|
});
|
|
1357
|
-
(0,
|
|
1519
|
+
(0, import_invariant5.invariant)(this._opened, "Closed", {
|
|
1520
|
+
F: __dxlog_file5,
|
|
1521
|
+
L: 128,
|
|
1522
|
+
S: this,
|
|
1523
|
+
A: [
|
|
1524
|
+
"this._opened",
|
|
1525
|
+
"'Closed'"
|
|
1526
|
+
]
|
|
1527
|
+
});
|
|
1358
1528
|
await this._forEachServer(async (server) => server.subscribeMessages(peerId));
|
|
1359
1529
|
}
|
|
1360
1530
|
async unsubscribeMessages(peerId) {
|
|
1361
1531
|
(0, import_log5.log)(`Subscribed for message stream peerId=${peerId}`, void 0, {
|
|
1362
1532
|
F: __dxlog_file5,
|
|
1363
|
-
L:
|
|
1533
|
+
L: 134,
|
|
1364
1534
|
S: this,
|
|
1365
1535
|
C: (f, a) => f(...a)
|
|
1366
1536
|
});
|
|
1367
|
-
(0,
|
|
1537
|
+
(0, import_invariant5.invariant)(this._opened, "Closed", {
|
|
1538
|
+
F: __dxlog_file5,
|
|
1539
|
+
L: 135,
|
|
1540
|
+
S: this,
|
|
1541
|
+
A: [
|
|
1542
|
+
"this._opened",
|
|
1543
|
+
"'Closed'"
|
|
1544
|
+
]
|
|
1545
|
+
});
|
|
1368
1546
|
await this._forEachServer(async (server) => server.unsubscribeMessages(peerId));
|
|
1369
1547
|
}
|
|
1370
1548
|
_initContext() {
|
|
1371
1549
|
this._ctx = new import_context4.Context({
|
|
1372
1550
|
onError: (err) => import_log5.log.catch(err, void 0, {
|
|
1373
1551
|
F: __dxlog_file5,
|
|
1374
|
-
L:
|
|
1552
|
+
L: 142,
|
|
1375
1553
|
S: this,
|
|
1376
1554
|
C: (f, a) => f(...a)
|
|
1377
1555
|
})
|