瀏覽代碼

Merge pull request #521 from afrokick/fix/fix-520

dataChannel can be null before initialization
afrokick 6 年之前
父節點
當前提交
f388c9a7b6
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      lib/negotiator.ts

+ 3 - 2
lib/negotiator.ts

@@ -193,8 +193,9 @@ export class Negotiator {
       const dataConnection = <DataConnection>this.connection;
       const dataChannel = dataConnection.dataChannel;
 
-      dataChannelNotClosed =
-        dataChannel.readyState && dataChannel.readyState !== "closed";
+      if (dataChannel) {
+        dataChannelNotClosed = !!dataChannel.readyState && dataChannel.readyState !== "closed";
+      }
     }
 
     if (peerConnectionNotClosed || dataChannelNotClosed) {