[html5] r4638 - [e] (0) Add a bufferedAmount example.
whatwg at whatwg.org
whatwg at whatwg.org
Sat Jan 30 23:53:01 PST 2010
Author: ianh
Date: 2010-01-30 23:53:00 -0800 (Sat, 30 Jan 2010)
New Revision: 4638
Modified:
complete.html
source
Log:
[e] (0) Add a bufferedAmount example.
Modified: complete.html
===================================================================
--- complete.html 2010-01-30 09:50:50 UTC (rev 4637)
+++ complete.html 2010-01-31 07:53:00 UTC (rev 4638)
@@ -110,7 +110,7 @@
<header class=head id=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
<hgroup><h1>Web Applications 1.0</h1>
- <h2 class="no-num no-toc">Draft Standard — 30 January 2010</h2>
+ <h2 class="no-num no-toc">Draft Standard — 31 January 2010</h2>
</hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
@@ -66734,6 +66734,30 @@
will only increase with each call to the <code title=dom-WebSocket-send><a href=#dom-websocket-send>send()</a></code> method (the number does not
reset to zero once the connection closes).</p>
+ <div class=example>
+
+ <p>In this simple example, the <code title=dom-WebSocket-bufferedAmount><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code>
+ attribute is used to ensure that updates are sent either at the
+ rate of one update every 50ms, if the network can handle that rate,
+ or at whatever rate the network <em>can</em> handle, if that is too
+ fast.</p>
+
+ <pre>var socket = new WebSocket('ws://game.example.com:12010/updates');
+socket.onopen = function () {
+ setInterval(function() {
+ if (socket.bufferedAmount == 0)
+ socket.send(getUpdateData());
+ }, 50);
+};</pre>
+
+ <p>The <code title=dom-WebSocket-bufferedAmount><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code>
+ attribute can also be used to saturate the network without sending
+ the data at a higher rate than the network can handle, though this
+ requires more careful monitoring of the value of the attribute over
+ time.</p>
+
+ </div>
+
<hr><p>The following are the <a href=#event-handlers>event handlers</a> that must be
supported, as IDL attributes, by all objects implementing the
<code><a href=#websocket>WebSocket</a></code> interface:</p>
Modified: source
===================================================================
--- source 2010-01-30 09:50:50 UTC (rev 4637)
+++ source 2010-01-31 07:53:00 UTC (rev 4638)
@@ -76195,6 +76195,32 @@
title="dom-WebSocket-send">send()</code> method (the number does not
reset to zero once the connection closes).</p>
+ <div class="example">
+
+ <p>In this simple example, the <code
+ title="dom-WebSocket-bufferedAmount">bufferedAmount</code>
+ attribute is used to ensure that updates are sent either at the
+ rate of one update every 50ms, if the network can handle that rate,
+ or at whatever rate the network <em>can</em> handle, if that is too
+ fast.</p>
+
+ <pre>var socket = new WebSocket('ws://game.example.com:12010/updates');
+socket.onopen = function () {
+ setInterval(function() {
+ if (socket.bufferedAmount == 0)
+ socket.send(getUpdateData());
+ }, 50);
+};</pre>
+
+ <p>The <code
+ title="dom-WebSocket-bufferedAmount">bufferedAmount</code>
+ attribute can also be used to saturate the network without sending
+ the data at a higher rate than the network can handle, though this
+ requires more careful monitoring of the value of the attribute over
+ time.</p>
+
+ </div>
+
<hr>
<p>The following are the <span>event handlers</span> that must be
More information about the Commit-Watchers
mailing list