[html5] r4427 - [giow] (1) Make the WebSocket API stop firing 'message' events as soon as close( [...]

whatwg at whatwg.org whatwg at whatwg.org
Wed Dec 9 10:40:05 PST 2009


Author: ianh
Date: 2009-12-09 10:39:58 -0800 (Wed, 09 Dec 2009)
New Revision: 4427

Modified:
   complete.html
   source
Log:
[giow] (1) Make the WebSocket API stop firing 'message' events as soon as close() is called. Also make close() change readyState to CLOSED.

Modified: complete.html
===================================================================
--- complete.html	2009-12-09 18:06:48 UTC (rev 4426)
+++ complete.html	2009-12-09 18:39:58 UTC (rev 4427)
@@ -65446,11 +65446,13 @@
 
   <p>The <dfn id=dom-websocket-close title=dom-WebSocket-close><code>close()</code></dfn>
   method must <a href=#close-the-web-socket-connection>close the Web Socket connection</a> or
-  connection attempt, if any. If the connection is already closed, it
-  must do nothing.</p>
+  connection attempt, if any, and change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value
+  to <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code> (2). If the
+  connection is already closed, it must do nothing.</p>
 
-  <p class=note>Closing the connection eventually causes a <code title=event-close>close</code> event to be fired and the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value
-  to change, as <a href=#closeWebSocket>described below</a>.</p>
+  <p class=note>Closing the connection immediately causes a task to
+  be queued to fire a <code title=event-close>close</code> event, as
+  <a href=#closeWebSocket>described below</a>.</p>
 
   <hr><p>The <dfn id=dom-websocket-bufferedamount title=dom-WebSocket-bufferedAmount><code>bufferedAmount</code></dfn>
   attribute must return the number of bytes that have been queued but
@@ -65469,34 +65471,30 @@
   </table><h4 id=feedback-from-the-protocol><span class=secno>10.3.3 </span>Feedback from the protocol</h4>
 
   <p>When the <i><a href=#web-socket-connection-is-established>Web Socket connection is established</a></i>, the user
-  agent must <a href=#queue-a-task>queue a task</a> to run the following steps:</p>
+  agent must <a href=#queue-a-task>queue a task</a> to first change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value
+  to <code title=dom-WebSocket-OPEN><a href=#dom-websocket-open>OPEN</a></code> (1), and then
+  <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-open>open</code> at the <code><a href=#websocket>WebSocket</a></code>
+  object.</p>
 
-  <ol><li>
-
-    <p>Change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value
-    to <code title=dom-WebSocket-OPEN><a href=#dom-websocket-open>OPEN</a></code> (1).</p>
-
-   </li>
-
-   <li>
-
-    <p><a href=#fire-a-simple-event>Fire a simple event</a> named <code title=event-open>open</code> at the <code><a href=#websocket>WebSocket</a></code>
-    object.</p>
-
-   </li>
-
-  </ol><hr><p>When <i>a Web Socket message has been received</i> with text <var title="">data</var>, the user agent must create an event that uses
+  <p>When <i>a Web Socket message has been received</i> with text <var title="">data</var>, the user agent must create an event that uses
   the <code><a href=#messageevent>MessageEvent</a></code> interface, with the event name <code title=event-message><a href=#event-message>message</a></code>, which does not bubble, is not
-  cancelable, has no default action, and whose <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute is set to <var title="">data</var>, and <a href=#queue-a-task>queue a task</a> to dispatch it at
-  the <code><a href=#websocket>WebSocket</a></code> object.</p>
-
-  <hr><p id=closeWebSocket>When the <i><a href=#web-socket-connection-is-closed>Web Socket connection is
-  closed</a></i>, must <a href=#queue-a-task>queue a task</a> to change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value
-  to <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code> (2) and then
-  <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-close>close</code> at the <code><a href=#websocket>WebSocket</a></code>
+  cancelable, has no default action, and whose <code title=dom-MessageEvent-data><a href=#dom-messageevent-data>data</a></code> attribute is set to <var title="">data</var>, and <a href=#queue-a-task>queue a task</a> to check to see
+  if the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code>
+  attribute's value is <code title=dom-WebSocket-OPEN><a href=#dom-websocket-open>OPEN</a></code>
+  (1), and if so, dispatch the event at the <code><a href=#websocket>WebSocket</a></code>
   object.</p>
 
-  <hr><p>The <a href=#task-source>task source</a> for all <a href=#concept-task title=concept-task>tasks</a> <a href=#queue-a-task title="queue a
+  <p id=closeWebSocket>When the <i><a href=#web-socket-connection-is-closed>Web Socket connection is
+  closed</a></i>, the user agent must <a href=#queue-a-task>queue a task</a> to first
+  change the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code>
+  attribute's value to <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code> (2), and then <a href=#fire-a-simple-event>fire
+  a simple event</a> named <code title=event-close>close</code>
+  at the <code><a href=#websocket>WebSocket</a></code> object. (If the <code title=dom-WebSocket-close><a href=#dom-websocket-close>close()</a></code> method was called, the
+  code title="dom-WebSocket-readyState">readyState attribute's
+  value will already be set to <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code> (2) when this task
+  runs.)</p>
+
+  <p>The <a href=#task-source>task source</a> for all <a href=#concept-task title=concept-task>tasks</a> <a href=#queue-a-task title="queue a
   task">queued</a> in this section is the <dfn id=web-socket-task-source>Web Socket task
   source</dfn>.</p>
 
@@ -66994,26 +66992,18 @@
 
   <p>To <dfn id=close-the-web-socket-connection>close the Web Socket connection</dfn>, either the user
   agent or the server closes the TCP/IP connection. There is no
-  closing handshake. Whether the user agent or the server closes the
-  connection, it is said that the <dfn id=web-socket-connection-is-closed>Web Socket connection is
+  closing handshake. When a user agent notices that the server has
+  closed its connection, it must immediately close its side of the
+  connection also. Whether the user agent or the server closes the
+  connection first, it is said that the <dfn id=web-socket-connection-is-closed>Web Socket connection is
   closed</dfn>.</p>
 
-  <p>When a user agent is to <a href=#close-the-web-socket-connection>close the Web Socket
-  connection</a>, it must drop all subsequent data from the server
-  and must act as if the server had immediately closed its side of the
-  connection.</p>
-
-  <p>When a user agent notices that the <a href=#web-socket-connection-is-closed>Web Socket connection is
-  closed</a>, it must immediately close its side of the
-  connection.</p>
-
   <p>Servers may <a href=#close-the-web-socket-connection>close the Web Socket connection</a> whenever
-  desired.</p>
-
-  <p>User agents should not <a href=#close-the-web-socket-connection>close the Web Socket
+  desired. User agents should not <a href=#close-the-web-socket-connection>close the Web Socket
   connection</a> arbitrarily.</p>
 
 
+
   <h5 id=security-considerations><span class=secno>10.3.4.6 </span>Security considerations</h5>
 
   <p>While this protocol is intended to be used by scripts in Web

Modified: source
===================================================================
--- source	2009-12-09 18:06:48 UTC (rev 4426)
+++ source	2009-12-09 18:39:58 UTC (rev 4427)
@@ -74635,17 +74635,17 @@
   (e.g. because the user agent just had a buffer overflow and failed
   to send the data).</p>
 
-  <p>The <dfn
-  title="dom-WebSocket-close"><code>close()</code></dfn>
+  <p>The <dfn title="dom-WebSocket-close"><code>close()</code></dfn>
   method must <span>close the Web Socket connection</span> or
-  connection attempt, if any. If the connection is already closed, it
-  must do nothing.</p>
-
-  <p class="note">Closing the connection eventually causes a <code
-  title="event-close">close</code> event to be fired and the <code
+  connection attempt, if any, and change the <code
   title="dom-WebSocket-readyState">readyState</code> attribute's value
-  to change, as <a href="#closeWebSocket">described below</a>.</p>
+  to <code title="dom-WebSocket-CLOSED">CLOSED</code> (2). If the
+  connection is already closed, it must do nothing.</p>
 
+  <p class="note">Closing the connection immediately causes a task to
+  be queued to fire a <code title="event-close">close</code> event, as
+  <a href="#closeWebSocket">described below</a>.</p>
+
   <hr>
 
   <p>The <dfn
@@ -74676,51 +74676,38 @@
   <h4>Feedback from the protocol</h4>
 
   <p>When the <i>Web Socket connection is established</i>, the user
-  agent must <span>queue a task</span> to run the following steps:</p>
+  agent must <span>queue a task</span> to first change the <code
+  title="dom-WebSocket-readyState">readyState</code> attribute's value
+  to <code title="dom-WebSocket-OPEN">OPEN</code> (1), and then
+  <span>fire a simple event</span> named <code
+  title="event-open">open</code> at the <code>WebSocket</code>
+  object.</p>
 
-  <ol>
-
-   <li>
-
-    <p>Change the <code
-    title="dom-WebSocket-readyState">readyState</code> attribute's value
-    to <code title="dom-WebSocket-OPEN">OPEN</code> (1).</p>
-
-   </li>
-
-   <li>
-
-    <p><span>Fire a simple event</span> named <code
-    title="event-open">open</code> at the <code>WebSocket</code>
-    object.</p>
-
-   </li>
-
-  </ol>
-
-  <hr>
-
   <p>When <i>a Web Socket message has been received</i> with text <var
   title="">data</var>, the user agent must create an event that uses
   the <code>MessageEvent</code> interface, with the event name <code
   title="event-message">message</code>, which does not bubble, is not
   cancelable, has no default action, and whose <code
   title="dom-MessageEvent-data">data</code> attribute is set to <var
-  title="">data</var>, and <span>queue a task</span> to dispatch it at
-  the <code>WebSocket</code> object.</p>
+  title="">data</var>, and <span>queue a task</span> to check to see
+  if the <code title="dom-WebSocket-readyState">readyState</code>
+  attribute's value is <code title="dom-WebSocket-OPEN">OPEN</code>
+  (1), and if so, dispatch the event at the <code>WebSocket</code>
+  object.</p>
 
-  <hr>
-
   <p id="closeWebSocket">When the <i>Web Socket connection is
-  closed</i>, must <span>queue a task</span> to change the <code
-  title="dom-WebSocket-readyState">readyState</code> attribute's value
-  to <code title="dom-WebSocket-CLOSED">CLOSED</code> (2) and then
-  <span>fire a simple event</span> named <code
-  title="event-close">close</code> at the <code>WebSocket</code>
-  object.</p>
+  closed</i>, the user agent must <span>queue a task</span> to first
+  change the <code title="dom-WebSocket-readyState">readyState</code>
+  attribute's value to <code
+  title="dom-WebSocket-CLOSED">CLOSED</code> (2), and then <span>fire
+  a simple event</span> named <code title="event-close">close</code>
+  at the <code>WebSocket</code> object. (If the <code
+  title="dom-WebSocket-close">close()</code> method was called, the
+  code title="dom-WebSocket-readyState">readyState</code> attribute's
+  value will already be set to <code
+  title="dom-WebSocket-CLOSED">CLOSED</code> (2) when this task
+  runs.)</p>
 
-  <hr>
-
   <p>The <span>task source</span> for all <span
   title="concept-task">tasks</span> <span title="queue a
   task">queued</span> in this section is the <dfn>Web Socket task
@@ -76425,26 +76412,18 @@
 
   <p>To <dfn>close the Web Socket connection</dfn>, either the user
   agent or the server closes the TCP/IP connection. There is no
-  closing handshake. Whether the user agent or the server closes the
-  connection, it is said that the <dfn>Web Socket connection is
+  closing handshake. When a user agent notices that the server has
+  closed its connection, it must immediately close its side of the
+  connection also. Whether the user agent or the server closes the
+  connection first, it is said that the <dfn>Web Socket connection is
   closed</dfn>.</p>
 
-  <p>When a user agent is to <span>close the Web Socket
-  connection</span>, it must drop all subsequent data from the server
-  and must act as if the server had immediately closed its side of the
-  connection.</p>
-
-  <p>When a user agent notices that the <span>Web Socket connection is
-  closed</span>, it must immediately close its side of the
-  connection.</p>
-
   <p>Servers may <span>close the Web Socket connection</span> whenever
-  desired.</p>
-
-  <p>User agents should not <span>close the Web Socket
+  desired. User agents should not <span>close the Web Socket
   connection</span> arbitrarily.</p>
 
 
+
   <h5>Security considerations</h5>
 
   <p>While this protocol is intended to be used by scripts in Web




More information about the Commit-Watchers mailing list