Sfoglia il codice sorgente

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

dataChannel can be null before initialization
afrokick 6 anni fa
parent
commit
f388c9a7b6
1 ha cambiato i file con 3 aggiunte e 2 eliminazioni
  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) {