断开连接后,peer.js如何重新连接到同一对等设备?

时间:2020-04-15 05:47:41

标签: webrtc peerjs

我需要知道在收到消息时通话中是否有2个对等方已连接-冰连接状态已断开,它将关闭所有窗口并断开2个对等方。 Ice Server断开连接时,我们可以处理重新连接吗?

这是iceconnectionstatechange的代码

pc.oniceconnectionstatechange = function() {
        switch (pc.iceConnectionState) {
          case "failed":
            util.log(
                "iceConnectionState is disconnected, closing connections to " + peerId
            );
            connection.emit(
                "error",
                new Error("Negotiation of connection to " + peerId + " failed.")
                );
                connection.close();
            break;
          case "disconnected":
            util.log(
                "iceConnectionState is disconnected, closing connections to " + peerId
                );

            connection.close();
            break;
          case "completed":
            pc.onicecandidate = util.noop;
            break;
        }
      };

0 个答案:

没有答案