Bladeren bron

reliable by default

Michelle Bu 11 jaren geleden
bovenliggende
commit
f34fff3dae
3 gewijzigde bestanden met toevoegingen van 10 en 9 verwijderingen
  1. 2 2
      docs/api.json
  2. 5 5
      docs/style.css
  3. 3 2
      lib/dataconnection.js

+ 2 - 2
docs/api.json

@@ -104,7 +104,7 @@
           {
             "name": "reliable",
             "type": "boolean",
-            "description": "[TODO: document this]."
+            "description": "Whether the underlying data channels should be reliable (e.g. for large file transfers) or not (e.g. for gaming or streaming). Defaults to <code>true</code>."
           }
         ]
       }
@@ -277,7 +277,7 @@
   {
     "name": "DataConnection",
     "type": "class",
-    "description": "Wraps WebRTC's DataChannel. To get one, use <a href='#peerconnect'><code>peer.connect</code></a> or listen for the <a href='#peeron-connect'><code>connect</code></a> event.<span class='tip'>Because Chrome currently does not support reliable messaging, PeerJS uses the <a href='https://github.com/michellebu/reliable'>Reliable shim</a>. A caveat is that you will no longer be able to customize the serialization format used for data transfer.</span>",
+    "description": "Wraps WebRTC's DataChannel. To get one, use <a href='#peerconnect'><code>peer.connect</code></a> or listen for the <a href='#peeron-connect'><code>connect</code></a> event.<span class='tip'>Because Chrome currently does not support reliable messaging, PeerJS uses the <a href='https://github.com/michellebu/reliable'>Reliable shim</a> when necessary. A caveat is that with the shim you will not be able to customize <code>serialization</code>.</span>",
     "children": [
       {
         "name": ".send",

+ 5 - 5
docs/style.css

@@ -171,15 +171,15 @@ body, html {
 .tip {
   opacity: 0.9;
   display: block;
-  background-color: #8F4537;
+  background-color: #d1c7be;
   font-size: 13px;
   line-height: 18px;
-  font-weight: 400;
+  font-weight: 600;
   border-radius: 2px;
   padding: 5px 8px;
-  color: #ddaba2;
-  border: 1px solid rgba(0,0,0,0.2);
-  text-shadow: 0px -1px 0px rgba(0,0,0,0.2);
+  color: #544e4a;
+  border: 1px solid #544e4a;
+  text-shadow: 0px -1px 0px rgba(255,255,255,0.2);
   margin: 8px 0 0 0;
 }
 

+ 3 - 2
lib/dataconnection.js

@@ -7,7 +7,8 @@ function DataConnection(peer, provider, options) {
 
   // TODO: perhaps default serialization should be binary-utf8?
   this.options = util.extend({
-    serialization: 'binary'
+    serialization: 'binary',
+    reliable: true
   }, options);
 
   // Connection is not open yet.
@@ -54,7 +55,7 @@ DataConnection.prototype._configureDataChannel = function() {
   }
 
   // Use the Reliable shim for non Firefox browsers
-  if (!util.supports.reliable) {
+  if (!util.supports.reliable && this.reliable) {
     this._reliable = new Reliable(this._dc, util.debug);
   }