Browse Source

Merge pull request #74 from JBYoshi/createanswer-fix

Fix bug where clients try to re-answer established connections.
RobinLinus 6 năm trước cách đây
mục cha
commit
fb7c5cd642
1 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 8 2
      client/scripts/network.js

+ 8 - 2
client/scripts/network.js

@@ -273,8 +273,14 @@ class RTCPeer extends Peer {
 
         if (message.sdp) {
             this._conn.setRemoteDescription(new RTCSessionDescription(message.sdp))
-                .then( _ => this._conn.createAnswer())
-                .then(d => this._onDescription(d))
+                .then( _ => {
+                    if (message.sdp.type == 'offer') {
+                        return this._conn.createAnswer()
+                            .then(d => this._onDescription(d));
+                    } else {
+                        return null;
+                    }
+                })
                 .catch(e => this._onError(e));
         } else if (message.ice) {
             this._conn.addIceCandidate(new RTCIceCandidate(message.ice));