Browse Source

dataChannel can be null before initialization

afrokick 6 năm trước cách đây
mục cha
commit
31bd3d67ee
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  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) {