Browse Source

one support

Michelle Bu 11 years ago
parent
commit
a359d10390
4 changed files with 20 additions and 5 deletions
  1. 1 1
      deps/reliable
  2. 1 1
      dist/peer.js
  3. 1 1
      lib/peer.js
  4. 17 2
      lib/util.js

+ 1 - 1
deps/reliable

@@ -1 +1 @@
-Subproject commit 0bbaf986efa550ea261b33ae20e17d85fb5b5bfa
+Subproject commit 856406373194f62fe68407eb680caa289a202a99

+ 1 - 1
dist/peer.js

@@ -1262,7 +1262,7 @@ function Peer(id, options) {
     host: util.CLOUD_HOST,
     port: util.CLOUD_PORT,
     key: 'peerjs',
-    config: { 'iceServers': [{ 'url': 'stun:stun.l.google.com:19302' }] }
+    config: util.defaultConfig()
   }, options);
   this.options = options;
   // Detect relative URL host.

+ 1 - 1
lib/peer.js

@@ -21,7 +21,7 @@ function Peer(id, options) {
     host: util.CLOUD_HOST,
     port: util.CLOUD_PORT,
     key: 'peerjs',
-    config: { 'iceServers': [{ 'url': 'stun:stun.l.google.com:19302' }] }
+    config: util.defaultConfig
   }, options);
   this.options = options;
   // Detect relative URL host.

+ 17 - 2
lib/util.js

@@ -61,12 +61,27 @@ var util = {
       audioVideo: true,
       data: true,
       binary: false,
-      reliable: false,
-      onnegotiationneeded: true
+      reliable: (function() {
+        // Reliable (not RTP).
+        var pc = new RTCPeerConnection(util.defaultConfig, {});
+        try {
+          pc.createDataChannel('PEERJSRELIABLETEST');
+        } catch (e) {
+          if (e.name === 'NotSupportedError') {
+            return false
+          }
+        }
+      })(),
+      onnegotiationneeded: true,
+      interop: false
     };
   }()),
   //
 
+  // Returns browser-agnostic default config
+  defaultConfig: {'iceServers': [{ 'url': 'stun:stun.l.google.com:19302' }]},
+  //
+
   // Ensure alphanumeric ids
   validateId: function(id) {
     // Allow empty ids