wireweave 0.3.19 → 0.3.20
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/package.json +1 -1
- package/src/voice.js +12 -4
package/package.json
CHANGED
package/src/voice.js
CHANGED
|
@@ -453,14 +453,17 @@ export class VoiceSession extends EventTarget {
|
|
|
453
453
|
}
|
|
454
454
|
if (data.action === 'leave') {
|
|
455
455
|
this.participants.delete(shortId);
|
|
456
|
+
this.sfu.pubkeyByShortId?.delete(shortId);
|
|
456
457
|
this._closePeer(event.pubkey);
|
|
457
458
|
if (this.sfu.hub === event.pubkey) this._sfuOnHubLost();
|
|
458
459
|
}
|
|
459
460
|
else if (!this.participants.has(shortId)) {
|
|
460
461
|
this.participants.set(shortId, { identity: data.name || event.pubkey.slice(0, 8), isSpeaking: false, isMuted: false, isLocal: false, hasVideo: false, connectionQuality: 'connecting' });
|
|
462
|
+
if (this.sfu.pubkeyByShortId) this.sfu.pubkeyByShortId.set(shortId, event.pubkey);
|
|
461
463
|
this._sfuMaybeElect();
|
|
462
464
|
this._maybeConnect(event.pubkey);
|
|
463
465
|
} else {
|
|
466
|
+
if (this.sfu.pubkeyByShortId && !this.sfu.pubkeyByShortId.has(shortId)) this.sfu.pubkeyByShortId.set(shortId, event.pubkey);
|
|
464
467
|
this._sfuMaybeElect();
|
|
465
468
|
if (this._sfuShouldHaveConnectionTo(event.pubkey) && !this.peers.has(event.pubkey)) this._maybeConnect(event.pubkey);
|
|
466
469
|
}
|
|
@@ -690,6 +693,7 @@ export class VoiceSession extends EventTarget {
|
|
|
690
693
|
this.sfu.lastSwitch = 0;
|
|
691
694
|
this.sfu.capacityMatrix = new Map();
|
|
692
695
|
this.sfu.reflexiveByPeer = new Map();
|
|
696
|
+
this.sfu.pubkeyByShortId = new Map();
|
|
693
697
|
this._sfuStopStats();
|
|
694
698
|
this.sfu.statsInterval = setInterval(() => this._sfuPoll(), 2500);
|
|
695
699
|
}
|
|
@@ -818,6 +822,7 @@ export class VoiceSession extends EventTarget {
|
|
|
818
822
|
this.sfu.hub = top.pubkey;
|
|
819
823
|
this.sfu.warmBackup = (runnerUp && runnerUp.pubkey !== top.pubkey) ? runnerUp.pubkey : null;
|
|
820
824
|
this.sfu.lastSwitch = Date.now();
|
|
825
|
+
try { this.sfu.actor?.send({ type: 'elect' }); } catch {}
|
|
821
826
|
this.sfu.actor?.send({ type: 'elected' });
|
|
822
827
|
this._emit('hub-changed', { hub: top.pubkey, previous: previousHub, score: top.score, uplink: top.uplink });
|
|
823
828
|
|
|
@@ -832,11 +837,13 @@ export class VoiceSession extends EventTarget {
|
|
|
832
837
|
// - Else: keep PCs only to hub + warm backup.
|
|
833
838
|
_sfuApplyTopology(hubPk) {
|
|
834
839
|
if (hubPk === this.auth.pubkey) {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
//
|
|
840
|
+
// Hub connects to every known participant. Build the pubkey set from
|
|
841
|
+
// every available source — pubkeyByShortId (presence-derived), peers,
|
|
842
|
+
// capacityMatrix, rttMatrix — because at the moment of the very first
|
|
843
|
+
// election the matrices may not be populated yet.
|
|
839
844
|
const known = new Set();
|
|
845
|
+
if (this.sfu.pubkeyByShortId) for (const pk of this.sfu.pubkeyByShortId.values()) known.add(pk);
|
|
846
|
+
for (const pk of this.peers.keys()) known.add(pk);
|
|
840
847
|
for (const pk of this.sfu.capacityMatrix?.keys() || []) known.add(pk);
|
|
841
848
|
for (const pk of this.sfu.rttMatrix.keys()) known.add(pk);
|
|
842
849
|
for (const pk of known) {
|
|
@@ -908,6 +915,7 @@ export class VoiceSession extends EventTarget {
|
|
|
908
915
|
this.sfu.hub = promote;
|
|
909
916
|
this.sfu.warmBackup = null;
|
|
910
917
|
this.sfu.lastSwitch = Date.now();
|
|
918
|
+
try { this.sfu.actor?.send({ type: 'elect' }); } catch {}
|
|
911
919
|
this.sfu.actor?.send({ type: 'elected' });
|
|
912
920
|
this._emit('hub-changed', { hub: promote, previous: lost, reason: 'failover' });
|
|
913
921
|
if (promote === this.auth.pubkey) this._sfuBecomeHub();
|