File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
packages/p2p-media-loader-core/src/p2p Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -97,23 +97,29 @@ export class P2PTrackerClient {
97
97
) => {
98
98
const itemId = Peer . getPeerIdFromConnection ( peerConnection ) ;
99
99
let peerItem = this . _peers . get ( itemId ) ;
100
+
100
101
if ( peerItem ?. peer ) {
101
102
peerConnection . destroy ( ) ;
102
103
return ;
103
- } else if ( ! peerItem ) {
104
+ }
105
+
106
+ if ( ! peerItem ) {
104
107
peerItem = { potentialConnections : new Set ( ) } ;
105
108
peerConnection . idUtf8 = itemId ;
106
- peerItem . potentialConnections . add ( peerConnection ) ;
107
109
this . _peers . set ( itemId , peerItem ) ;
108
110
}
109
111
112
+ peerItem . potentialConnections . add ( peerConnection ) ;
113
+
110
114
peerConnection . on ( "connect" , ( ) => {
111
115
if ( peerItem . peer ) return ;
112
116
113
117
for ( const connection of peerItem . potentialConnections ) {
114
118
if ( connection !== peerConnection ) connection . destroy ( ) ;
115
119
}
120
+
116
121
peerItem . potentialConnections . clear ( ) ;
122
+
117
123
peerItem . peer = new Peer (
118
124
peerConnection ,
119
125
{
You can’t perform that action at this time.
0 commit comments