Преглед изворни кода

fix(strophe.jingle.js): exception on ICE config modification

If ICE config object gets modified while there's any native
PeerConnection instance holding a reference, it will cause
an exception about final object being modified.

It happens when trying to reconnect XMPP Websocket on RN and
is caused by the fact that new TURN config is fetched after
the connection is re-established.
tags/v0.0.2
paweldomas пре 5 година
родитељ
комит
adc87bcffd
1 измењених фајлова са 7 додато и 1 уклоњено
  1. 7
    1
      modules/xmpp/strophe.jingle.js

+ 7
- 1
modules/xmpp/strophe.jingle.js Прегледај датотеку

149
             logger.info(
149
             logger.info(
150
                 `Marking session from ${fromJid
150
                 `Marking session from ${fromJid
151
                 } as ${isP2P ? '' : '*not*'} P2P`);
151
                 } as ${isP2P ? '' : '*not*'} P2P`);
152
+
153
+            const iceConfig = isP2P ? this.p2pIceConfig : this.jvbIceConfig;
154
+
152
             sess
155
             sess
153
                 = new JingleSessionPC(
156
                 = new JingleSessionPC(
154
                     $(iq).find('jingle').attr('sid'),
157
                     $(iq).find('jingle').attr('sid'),
156
                     fromJid,
159
                     fromJid,
157
                     this.connection,
160
                     this.connection,
158
                     this.mediaConstraints,
161
                     this.mediaConstraints,
159
-                    isP2P ? this.p2pIceConfig : this.jvbIceConfig,
162
+
163
+                    // Makes a copy in order to prevent exception thrown on RN when either this.p2pIceConfig or
164
+                    // this.jvbIceConfig is modified and there's a PeerConnection instance holding a reference
165
+                    JSON.parse(JSON.stringify(iceConfig)),
160
                     isP2P,
166
                     isP2P,
161
                     /* initiator */ false);
167
                     /* initiator */ false);
162
 
168
 

Loading…
Откажи
Сачувај