1

我正在尝试将 simple-peer 与 react-native-webrtc 包一起使用来创建连接。我相信这是这里的问题,但还没有找到任何解决方案。https://github.com/feross/simple-peer/issues/109#issuecomment-576302328

这是我的客户端代码,当新的对等点加入时,它将通过 socket.io 发送其信息,因此第一个对等点可以将其添加为对等点:

this.socketRef.on("user joined", payload => {
        const peer = this.addPeer(payload.signal, payload.callerID)
        this.peersRef.push({
          peerID: payload.callerID,
          peer,
        })

        const peerObj = {
          peer,
          peerID: payload.callerID
        }

        this.peers.push(peerObj)
      })
addPeer(incomingSignal, callerID) {
    const peer = new Peer({
      initiator: false,
      trickle: false,
      stream: this.stream
    })

    peer.on("signal", signal => {
        this.socketRef.emit("returning signal", {signal, callerID})
    })

    peer.signal(incomingSignal) 

    return peer
  }

但我收到此错误:

Error: No WebRTC support: Not a supported browser

任何帮助表示赞赏

4

1 回答 1

0

你可以这样打电话

const peer = new Peer(
 {initiator: true, 
 wrtc: { 
  RTCPeerConnection,
  RTCIceCandidate,
  RTCSessionDescription,
  RTCView,
  MediaStream,
  MediaStreamTrack,
  mediaDevices,
  registerGlobals
  },
});

于 2021-05-30T20:15:10.907 回答