How to use the react-native-webrtc.RTCIceCandidate function in react-native-webrtc

To help you get started, we’ve selected a few react-native-webrtc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BrightID / BrightID / BrightID-rn / src / components / WebrtcScreens / RtcAnswerScreen.js View on Github external
setIceCandidate = async (candidate) => {
    try {
      // set ice candidate
      if (this.connection && candidate) {
        await this.connection.addIceCandidate(new RTCIceCandidate(candidate));
      }
    } catch (err) {
      // error setting ice candidate?
      console.log(err);
    }
  };
github DimitrisTzimikas / RCTWebRTCDemo2 / src / App.js View on Github external
peer = pcPeers[fromId];
  } else {
    peer = createPC(fromId, false);
  }
  
  if (data.sdp) {
    //console.log('exchange sdp', data);
    let sdp = new RTCSessionDescription(data.sdp);
    
    let callback = () => peer.remoteDescription.type === 'offer' ? peer.createAnswer(callback2, logError) : null;
    let callback2 = desc => peer.setLocalDescription(desc, callback3, logError);
    let callback3 = () => socket.emit('exchange', { to: fromId, sdp: peer.localDescription });
    
    peer.setRemoteDescription(sdp, callback, logError);
  } else {
    peer.addIceCandidate(new RTCIceCandidate(data.candidate));
  }
};
github 0mkara / RNAWebRTCApp / src / webrtcMiddleware.js View on Github external
peerconn.setRemoteDescription(new RTCSessionDescription(data.sdp))
                .then(() => {
                    if (peerconn.remoteDescription.type === "offer") {
                        peerconn.createAnswer(offerOpts)
                            .then(desc => {
                                peerconn.setLocalDescription(desc)
                                    .then(() => {
                                        store.dispatch({ type: EXCHANGE, payload: {'to': data.from, 'sdp': peerconn.localDescription } });
                                    })
                                    .catch(err => console.error("exchange sdp error : ", err))
                            })
                    }
                })
        } else {
            console.log('exchange candidate');
            peerconn.addIceCandidate(new RTCIceCandidate(data.candidate));
        }
    }
    return store => next => action => {
github sieuhuflit / react-native-live-stream-webrtc-example / src / PeerConnectionUtils.js View on Github external
SocketUtils.emitExchangeServerSdp(
                      fromId,
                      pc.localDescription
                    );
                  },
                  error => console.log('error : ' + error)
                );
              },
              error => console.log('error : ' + error)
            );
        },
        error => console.log('error : ' + error)
      );
    } else {
      console.log('exchange candidate', data);
      pc.addIceCandidate(new RTCIceCandidate(data.candidate));
    }
  }
};