- From: poot <cvsmail@w3.org>
- Date: Thu, 23 Apr 2009 07:21:53 +0900 (JST)
- To: public-html-diffs@w3.org
W3C policy: fear of change, caution to the point of paralysis. Let's change the world, but without taking any risks! (whatwg r2973) WebSocket http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#websocket Abstract http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#abstract disconnect() http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#dom-websocket-disconnect References http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#references URL http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#dom-websocket-url 5.1 Garbage collection http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#garbage-collection Web Socket task source http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#web-socket-task-source When the Web Socket connection is closed, the readyState attribute's value must be changed to CLOSED (2), and the user agent must queue a task to fire a simple event named close at the WebSocket object. http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#closeWebSocket 1 Introduction http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#network-intro WebSocket(url) http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#dom-websocket CONNECTING http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#dom-websocket-connecting readyState http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#dom-websocket-readystate onmessage http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#handler-websocket-onmessage CLOSED http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#dom-websocket-closed 2 Conformance requirements http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#conformance-requirements 4 The WebSocket interface http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#the-websocket-interface onopen http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#handler-websocket-onopen onclose http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#handler-websocket-onclose Status of this document http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#status-of-this-document OPEN http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#dom-websocket-open 5 Feedback from the protocol http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#feedback-from-the-protocol W3C Working Draft 23 April 2009 http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#w3c-working-draft-23-april-year 2.1 Dependencies http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#dependencies postMessage(data) http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#dom-websocket-postmessage 3 Terminology http://people.w3.org/mike/diffs/html5/websockets/Overview.1.67.html#terminology http://people.w3.org/mike/diffs/html5/websockets/Overview.diff.html http://dev.w3.org/cvsweb/html5/websockets/Overview.html?r1=1.66&r2=1.67&f=h http://html5.org/tools/web-apps-tracker?from=2972&to=2973 =================================================================== RCS file: /sources/public/html5/websockets/Overview.html,v retrieving revision 1.66 retrieving revision 1.67 diff -u -d -r1.66 -r1.67 --- Overview.html 22 Apr 2009 19:26:12 -0000 1.66 +++ Overview.html 22 Apr 2009 22:21:26 -0000 1.67 @@ -1,4 +1,4 @@ -<!DOCTYPE html><!-- when publishing, change bits marked ZZZ --><html lang=en-US-x-Hixie><title>The Web Sockets API</title><style type=text/css> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- when publishing, change bits marked ZZZ --><html lang="en-US-x-Hixie"><title>The Web Sockets API</title><style type="text/css"> pre { margin-left: 2em; white-space: pre-wrap; } h2 { margin: 3em 0 1em 0; } h3 { margin: 2.5em 0 1em 0; } @@ -142,55 +142,55 @@ -webkit-column-width: 25em; -webkit-column-gap: 1em; } - </style><link href=http://www.w3.org/StyleSheets/TR/W3C-WD rel=stylesheet type=text/css><!-- ZZZ ED vs WD --><div class=head> - <p><a href=http://www.w3.org/><img alt=W3C height=48 src=http://www.w3.org/Icons/w3c_home width=72></a></p> + </style><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css"><!-- ZZZ ED vs WD --><div class="head"> + <p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p> <h1>The Web Sockets API</h1> <!--ZZZ:--> - <h2 class="no-num no-toc" id=w3c-working-draft-23-april-year>W3C Working Draft 23 April 2009</h2> + <h2 class="no-num no-toc" id="w3c-working-draft-23-april-year">W3C Working Draft 23 April 2009</h2> <!--<h2 class="no-num no-toc">Editor's Draft 22 April 2009</h2>--> <!--:ZZZ--> <dl><!-- ZZZ: update the month/day (twice), (un)comment out--><dt>This Version:</dt> - <dd><a href=http://www.w3.org/TR/2009/WD-websockets-20090423/>http://www.w3.org/TR/2009/WD-websockets-20090423/</a></dd> + <dd><a href="http://www.w3.org/TR/2009/WD-websockets-20090423/">http://www.w3.org/TR/2009/WD-websockets-20090423/</a></dd> <!-- :ZZZ --> <dt>Latest Published Version:</dt> - <dd><a href=http://www.w3.org/TR/websockets/>http://www.w3.org/TR/websockets/</a></dd> + <dd><a href="http://www.w3.org/TR/websockets/">http://www.w3.org/TR/websockets/</a></dd> <dt>Latest Editor's Draft:</dt> - <dd><a href=http://dev.w3.org/html5/websockets/>http://dev.w3.org/html5/websockets/</a></dd> + <dd><a href="http://dev.w3.org/html5/websockets/">http://dev.w3.org/html5/websockets/</a></dd> <!-- ZZZ: add the new version after it has shipped <dt>Previous Versions:</dt> <dd><a href="http://www.w3.org/TR/2009/WD-websockets-20090423/">http://www.w3.org/TR/2009/WD-websockets-20090423/</a> :ZZZ --> <dt>Editors:</dt> - <dd><a href=mailto:ian@hixie.ch>Ian Hickson</a>, Google, Inc.</dd> - </dl><p class=copyright><a href=http://www.w3.org/Consortium/Legal/ipr-notice#Copyright>Copyright</a> - © 2009 <a href=http://www.w3.org/><abbr title="World Wide - Web Consortium">W3C</abbr></a><sup>®</sup> (<a href=http://www.csail.mit.edu/><abbr title="Massachusetts - Institute of Technology">MIT</abbr></a>, <a href=http://www.ercim.org/><abbr title="European Research - Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href=http://www.keio.ac.jp/>Keio</a>), All Rights Reserved. W3C - <a href=http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer>liability</a>, - <a href=http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks>trademark</a> - and <a href=http://www.w3.org/Consortium/Legal/copyright-documents>document + <dd><a href="mailto:ian@hixie.ch">Ian Hickson</a>, Google, Inc.</dd> + </dl><p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> + © 2009 <a href="http://www.w3.org/"><abbr title="World Wide + Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts + Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.org/"><abbr title="European Research + Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C + <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, + <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> + and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p> - </div><hr class=top><h2 class="no-num no-toc" id=abstract>Abstract</h2><p>This specification defines an API that enables Web pages to use + </div><hr class="top"><h2 class="no-num no-toc" id="abstract">Abstract</h2><p>This specification defines an API that enables Web pages to use the Web Sockets protocol for two-way communication with a remote - host.<h2 class="no-num no-toc" id=status-of-this-document>Status of this document</h2><!-- intro boilerplate (required) --><p><em>This section describes the status of this document at the + host.<h2 class="no-num no-toc" id="status-of-this-document">Status of this document</h2><!-- intro boilerplate (required) --><p><em>This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the most recently formally published revision of this technical report can be found in - the <a href=http://www.w3.org/TR/>W3C technical reports index</a> + the <a href="http://www.w3.org/TR/">W3C technical reports index</a> at http://www.w3.org/TR/.</em></p><!-- where to send feedback (required) --><p>If you wish to make comments regarding this document, please send - them to <a href=mailto:public-webapps@w3.org>public-webapps@w3.org</a> + them to <a href="mailto:public-webapps@w3.org">public-webapps@w3.org</a> (<a href="mailto:public-webapps-request@w3.org?subject=subscribe">subscribe</a>, - <a href=http://lists.w3.org/Archives/Public/public-webapps/>archives</a>), + <a href="http://lists.w3.org/Archives/Public/public-webapps/">archives</a>), <!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING SENTENCE TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --> - <a href=mailto:whatwg@whatwg.org>whatwg@whatwg.org</a> (<a href=http://lists.whatwg.org/listinfo.cgi/whatwg-whatwg.org>subscribe</a>, - <a href=http://lists.whatwg.org/pipermail/whatwg-whatwg.org/>archives</a>), + <a href="mailto:whatwg@whatwg.org">whatwg@whatwg.org</a> (<a href="http://lists.whatwg.org/listinfo.cgi/whatwg-whatwg.org">subscribe</a>, + <a href="http://lists.whatwg.org/pipermail/whatwg-whatwg.org/">archives</a>), <!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING SENTENCE TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --> - or <a href=mailto:hybi@ietf.org>hybi@ietf.org</a> (<a href=https://www.ietf.org/mailman/listinfo/hybi>subscribe</a>, - <a href=http://www.ietf.org/mail-archive/web/hybi/current/maillist.html>archives</a>). + or <a href="mailto:hybi@ietf.org">hybi@ietf.org</a> (<a href="https://www.ietf.org/mailman/listinfo/hybi">subscribe</a>, + <a href="http://www.ietf.org/mail-archive/web/hybi/current/maillist.html">archives</a>). All feedback is welcome.</p><!-- stability (required) --><p>Implementors should be aware that this specification is not stable. <strong>Implementors who are not taking part in the @@ -199,19 +199,19 @@ implementing this specification before it eventually reaches the Candidate Recommendation stage should join the aforementioned mailing lists and take part in the discussions.</p><!-- version history or list of changes (required) --><p>The latest stable version of the editor's draft of this - specification is always available on <a href=http://dev.w3.org/html5/websockets/Overview.html>the W3C CVS + specification is always available on <a href="http://dev.w3.org/html5/websockets/Overview.html">the W3C CVS server</a>. Change tracking for this document is available at the - following location:<ul><li>CVS log: <a href=http://dev.w3.org/cvsweb/html5/websockets/Overview.html>http://dev.w3.org/cvsweb/html5/websockets/Overview.html</a></li> + following location:<ul><li>CVS log: <a href="http://dev.w3.org/cvsweb/html5/websockets/Overview.html">http://dev.w3.org/cvsweb/html5/websockets/Overview.html</a></li> </ul><!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- relationship to other work (required) --><p>This specification is automatically generated from the corresponding section in the HTML5 specification's source document, - as hosted in the <a href=http://svn.whatwg.org/webapps/>WHATWG + as hosted in the <a href="http://svn.whatwg.org/webapps/">WHATWG Subversion repository</a>. Detailed change history for all of HTML5, including the parts that form this specification, can be found at - the following locations:</p><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING LIST TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><ul><li>Twitter messages (non-editorial changes only): <a href=http://twitter.com/WHATWG>http://twitter.com/WHATWG</a></li> - <li>Interactive Web interface: <a href=http://html5.org/tools/web-apps-tracker>http://html5.org/tools/web-apps-tracker</a></li> - <li>Commit-Watchers mailing list: <a href=http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org>http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org</a></li> - <li>Subversion interface: <a href=http://svn.whatwg.org/webapps/>http://svn.whatwg.org/webapps/</a></li> - </ul><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING LIST TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- status of document, group responsible (required) --><p>The W3C <a href=http://www.w3.org/2008/webapps/>Web Apps + the following locations:</p><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING LIST TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><ul><li>Twitter messages (non-editorial changes only): <a href="http://twitter.com/WHATWG">http://twitter.com/WHATWG</a></li> + <li>Interactive Web interface: <a href="http://html5.org/tools/web-apps-tracker">http://html5.org/tools/web-apps-tracker</a></li> + <li>Commit-Watchers mailing list: <a href="http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org">http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org</a></li> + <li>Subversion interface: <a href="http://svn.whatwg.org/webapps/">http://svn.whatwg.org/webapps/</a></li> + </ul><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING LIST TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- status of document, group responsible (required) --><p>The W3C <a href="http://www.w3.org/2008/webapps/">Web Apps Working Group</a> is the W3C working group responsible for this specification's progress along the W3C Recommendation track. <!--ZZZ:--> @@ -220,40 +220,40 @@ <!--:ZZZ--> <p>This specification is being developed in conjunction with an Internet Draft for a wire protocol, the Web Socket Protocol, - available from the IETF at the following location:<ul><li>WebSocket Protocol Internet-Draft: <a href=http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol>http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol</a></li> - </ul><!-- required patent boilerplate --><p>This document was produced by a group operating under the <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/>5 - February 2004 W3C Patent Policy</a>. W3C maintains a <a href=http://www.w3.org/2004/01/pp-impl/42538/status rel=disclosure>public list of + available from the IETF at the following location:<ul><li>WebSocket Protocol Internet-Draft: <a href="http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol">http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol</a></li> + </ul><!-- required patent boilerplate --><p>This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 + February 2004 W3C Patent Policy</a>. W3C maintains a <a href="http://www.w3.org/2004/01/pp-impl/42538/status" rel="disclosure">public list of any patent disclosures</a> made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the - individual believes contains <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential>Essential - Claim(s)</a> must disclose the information in accordance with <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure>section - 6 of the W3C Patent Policy</a>.<h2 class="no-num no-toc" id=contents>Table of contents</h2> + individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential + Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section + 6 of the W3C Patent Policy</a>.<h2 class="no-num no-toc" id="contents">Table of contents</h2> <!--begin-toc--> -<ol class=toc> - <li><a href=#network-intro><span class=secno>1 </span>Introduction</a></li> - <li><a href=#conformance-requirements><span class=secno>2 </span>Conformance requirements</a> +<ol class="toc"> + <li><a href="#network-intro"><span class="secno">1 </span>Introduction</a></li> + <li><a href="#conformance-requirements"><span class="secno">2 </span>Conformance requirements</a> <ol> - <li><a href=#dependencies><span class=secno>2.1 </span>Dependencies</a></ol></li> - <li><a href=#terminology><span class=secno>3 </span>Terminology</a></li> - <li><a href=#the-websocket-interface><span class=secno>4 </span>The <code>WebSocket</code> interface</a></li> - <li><a href=#feedback-from-the-protocol><span class=secno>5 </span>Feedback from the protocol</a> + <li><a href="#dependencies"><span class="secno">2.1 </span>Dependencies</a></ol></li> + <li><a href="#terminology"><span class="secno">3 </span>Terminology</a></li> + <li><a href="#the-websocket-interface"><span class="secno">4 </span>The <code>WebSocket</code> interface</a></li> + <li><a href="#feedback-from-the-protocol"><span class="secno">5 </span>Feedback from the protocol</a> <ol> - <li><a href=#garbage-collection><span class=secno>5.1 </span>Garbage collection</a></ol></li> - <li><a class=no-num href=#references>References</a></ol> -<!--end-toc--><hr><h2 id=network-intro><span class=secno>1 </span>Introduction</h2><p><em>This section is non-normative.</em><p>To enable Web applications to maintain bidirectional + <li><a href="#garbage-collection"><span class="secno">5.1 </span>Garbage collection</a></ol></li> + <li><a class="no-num" href="#references">References</a></ol> +<!--end-toc--><hr><h2 id="network-intro"><span class="secno">1 </span>Introduction</h2><p><em>This section is non-normative.</em><p>To enable Web applications to maintain bidirectional communications with server-side processes, this specification - introduces the <code><a href=#websocket>WebSocket</a></code> interface.<p class=note>This interface does not allow for raw access to the + introduces the <code><a href="#websocket">WebSocket</a></code> interface.<p class="note">This interface does not allow for raw access to the underlying network. For example, this interface could not be used to implement an IRC client without proxying messages through a custom - server.<p class=XXX>An introduction to the client-side and - server-side of using the direct connection APIs.<h2 id=conformance-requirements><span class=secno>2 </span>Conformance requirements</h2><p>All diagrams, examples, and notes in this specification are + server.<p class="XXX">An introduction to the client-side and + server-side of using the direct connection APIs.<h2 id="conformance-requirements"><span class="secno">2 </span>Conformance requirements</h2><p>All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative.<p>The key words "MUST", "MUST NOT", "REQUIRED", <!--"SHALL", "SHALL NOT",--> "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC2119. For readability, these words do - not appear in all uppercase letters in this specification. <a href=#references>[RFC2119]</a><p>Requirements phrased in the imperative as part of algorithms + not appear in all uppercase letters in this specification. <a href="#references">[RFC2119]</a><p>Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the meaning of the key word ("must", "should", "may", etc) used in introducing the @@ -267,13 +267,13 @@ agents.<p>User agents may impose implementation-specific limits on otherwise unconstrained inputs, e.g. to prevent denial of service attacks, to guard against running out of memory, or to work around - platform-specific limitations.<h3 id=dependencies><span class=secno>2.1 </span>Dependencies</h3><p>This specification relies on several other underlying + platform-specific limitations.<h3 id="dependencies"><span class="secno">2.1 </span>Dependencies</h3><p>This specification relies on several other underlying specifications.<dl><dt>HTML5</dt> <dd> <p>Many fundamental concepts from HTML5 are used by this - specification. <a href=#references>[HTML5]</a></p> + specification. <a href="#references">[HTML5]</a></p> </dd> @@ -282,147 +282,147 @@ <dd> <p>The IDL blocks in this specification use the semantics of the - WebIDL specification. <a href=#references>[WebIDL]</a></p> + WebIDL specification. <a href="#references">[WebIDL]</a></p> </dd> - </dl><h2 id=terminology><span class=secno>3 </span>Terminology</h2><p>The construction "a <code title="">Foo</code> object", where + </dl><h2 id="terminology"><span class="secno">3 </span>Terminology</h2><p>The construction "a <code title="">Foo</code> object", where <code title="">Foo</code> is actually an interface, is sometimes used instead of the more accurate "an object implementing the interface <code title="">Foo</code>".<p>The term DOM is used to refer to the API set made available to scripts in Web applications, and does not necessarily imply the existence of an actual <code>Document</code> object or of any other <code>Node</code> objects as defined in the DOM Core - specifications. <a href=#references>[DOM3CORE]</a><p>A DOM attribute is said to be <em>getting</em> when its value is + specifications. <a href="#references">[DOM3CORE]</a><p>A DOM attribute is said to be <em>getting</em> when its value is being retrieved (e.g. by author script), and is said to be - <em>setting</em> when a new value is assigned to it.<h2 id=the-websocket-interface><span class=secno>4 </span>The <code><a href=#websocket>WebSocket</a></code> interface</h2><pre class=idl>[<a href=#dom-websocket title=dom-WebSocket>Constructor</a>(in DOMString url)] -interface <dfn id=websocket>WebSocket</dfn> { - readonly attribute DOMString <a href=#dom-websocket-url title=dom-WebSocket-URL>URL</a>; + <em>setting</em> when a new value is assigned to it.<h2 id="the-websocket-interface"><span class="secno">4 </span>The <code><a href="#websocket">WebSocket</a></code> interface</h2><pre class="idl">[<a href="#dom-websocket" title="dom-WebSocket">Constructor</a>(in DOMString url)] +interface <dfn id="websocket">WebSocket</dfn> { + readonly attribute DOMString <a href="#dom-websocket-url" title="dom-WebSocket-URL">URL</a>; // ready state - const unsigned short <a href=#dom-websocket-connecting title=dom-WebSocket-CONNECTING>CONNECTING</a> = 0; - const unsigned short <a href=#dom-websocket-open title=dom-WebSocket-OPEN>OPEN</a> = 1; - const unsigned short <a href=#dom-websocket-closed title=dom-WebSocket-CLOSED>CLOSED</a> = 2; - readonly attribute long <a href=#dom-websocket-readystate title=dom-WebSocket-readyState>readyState</a>; + const unsigned short <a href="#dom-websocket-connecting" title="dom-WebSocket-CONNECTING">CONNECTING</a> = 0; + const unsigned short <a href="#dom-websocket-open" title="dom-WebSocket-OPEN">OPEN</a> = 1; + const unsigned short <a href="#dom-websocket-closed" title="dom-WebSocket-CLOSED">CLOSED</a> = 2; + readonly attribute long <a href="#dom-websocket-readystate" title="dom-WebSocket-readyState">readyState</a>; // networking - attribute <span>Function</span> <a href=#handler-websocket-onopen title=handler-WebSocket-onopen>onopen</a>; - attribute <span>Function</span> <a href=#handler-websocket-onmessage title=handler-WebSocket-onmessage>onmessage</a>; - attribute <span>Function</span> <a href=#handler-websocket-onclose title=handler-WebSocket-onclose>onclose</a>; - void <a href=#dom-websocket-postmessage title=dom-WebSocket-postMessage>postMessage</a>(in DOMString data); - void <a href=#dom-websocket-disconnect title=dom-WebSocket-disconnect>disconnect</a>(); -};</pre><p><code><a href=#websocket>WebSocket</a></code> objects must also implement the - <code>EventTarget</code> interface. <a href=#references>[DOM3EVENTS]</a> + attribute <span>Function</span> <a href="#handler-websocket-onopen" title="handler-WebSocket-onopen">onopen</a>; + attribute <span>Function</span> <a href="#handler-websocket-onmessage" title="handler-WebSocket-onmessage">onmessage</a>; + attribute <span>Function</span> <a href="#handler-websocket-onclose" title="handler-WebSocket-onclose">onclose</a>; + void <a href="#dom-websocket-postmessage" title="dom-WebSocket-postMessage">postMessage</a>(in DOMString data); + void <a href="#dom-websocket-disconnect" title="dom-WebSocket-disconnect">disconnect</a>(); +};</pre><p><code><a href="#websocket">WebSocket</a></code> objects must also implement the + <code>EventTarget</code> interface. <a href="#references">[DOM3EVENTS]</a> - <p>The <dfn id=dom-websocket title=dom-WebSocket><code>WebSocket(<var title="">url</var>)</code></dfn> constructor takes one argument, + <p>The <dfn id="dom-websocket" title="dom-WebSocket"><code>WebSocket(<var title="">url</var>)</code></dfn> constructor takes one argument, <var title="">url</var>, which specifies the <span>URL</span> to which to connect. When the <code>WebSocket()</code> constructor is invoked, the UA must run these steps:<ol><li><p><span title="parse a url">Parse</span> the <var title="">url</var> argument.</li> <li><p>If the previous step failed, or if <var title="">url</var> - does not have a <span title=url-scheme><scheme></span> + does not have a <span title="url-scheme"><scheme></span> component whose value is either "<code title="">ws</code>" or "<code title="">wss</code>", when compared in an <span>ASCII case-insensitive</span> manner, then throw a <code>SYNTAX_ERR</code> exception.</li> - <li><p>Return a new <code><a href=#websocket>WebSocket</a></code> object, and continue + <li><p>Return a new <code><a href="#websocket">WebSocket</a></code> object, and continue these steps in the background (without blocking scripts).</li> <li><p>Let <var title="">origin</var> be the <span title="ASCII serialization of an origin">ASCII serialization</span> of the - <span>origin</span> of the script that invoked the <code title=dom-WebSocket><a href=#dom-websocket>WebSocket()</a></code> constructor, + <span>origin</span> of the script that invoked the <code title="dom-WebSocket"><a href="#dom-websocket">WebSocket()</a></code> constructor, <span>converted to lowercase</span>.</li> - <li><p>If the <span title=url-scheme><scheme></span> + <li><p>If the <span title="url-scheme"><scheme></span> component of <var title="">url</var> is "<code title="">ws</code>", - set <var title="">secure</var> to false; otherwise, the <span title=url-scheme><scheme></span> component is "<code title="">wss</code>", set <var title="">secure</var> to + set <var title="">secure</var> to false; otherwise, the <span title="url-scheme"><scheme></span> component is "<code title="">wss</code>", set <var title="">secure</var> to true.</li> - <li><p>Let <var title="">host</var> be the value of the <span title=url-host><host></span> component of <var title="">url</var>, <span>converted to lowercase</span>.</li> + <li><p>Let <var title="">host</var> be the value of the <span title="url-host"><host></span> component of <var title="">url</var>, <span>converted to lowercase</span>.</li> - <li><p>If <var title="">url</var> has a <span title=url-port><port></span> component, then let <var title="">port</var> be that component's value; otherwise, there is + <li><p>If <var title="">url</var> has a <span title="url-port"><port></span> component, then let <var title="">port</var> be that component's value; otherwise, there is no explicit <var title="">port</var>.</li> <li><p>Let <var title="">resource name</var> be the value of the - <span title=url-path><path></span> component (which might + <span title="url-path"><path></span> component (which might be empty) of <var title="">url</var>.</li> <li><p>If <var title="">resource name</var> is the empty string, set it to a single character U+002F SOLIDUS (/).</li> - <li><p>If <var title="">url</var> has a <span title=url-query><query></span> component, then append a + <li><p>If <var title="">url</var> has a <span title="url-query"><query></span> component, then append a single U+003F QUESTION MARK (?) character to <var title="">resource - name</var>, followed by the value of the <span title=url-query><query></span> component.</li> + name</var>, followed by the value of the <span title="url-query"><query></span> component.</li> <li><p><span>Establish a Web Socket connection</span> to a host <var title="">host</var>, on port <var title="">port</var> (if one was specified), from <var title="">origin</var>, with the flag <var title="">secure</var>, and with <var title="">resource name</var> as the resource name.</li> - </ol><hr><p>The <dfn id=dom-websocket-url title=dom-WebSocket-URL><code>URL</code></dfn> + </ol><hr><p>The <dfn id="dom-websocket-url" title="dom-WebSocket-URL"><code>URL</code></dfn> attribute must return the value that was passed to the - constructor.<p>The <dfn id=dom-websocket-readystate title=dom-WebSocket-readyState><code>readyState</code></dfn> + constructor.<p>The <dfn id="dom-websocket-readystate" title="dom-WebSocket-readyState"><code>readyState</code></dfn> attribute represents the state of the connection. It can have the - following values:<dl><dt><dfn id=dom-websocket-connecting title=dom-WebSocket-CONNECTING><code>CONNECTING</code></dfn> (numeric value 0)</dt> + following values:<dl><dt><dfn id="dom-websocket-connecting" title="dom-WebSocket-CONNECTING"><code>CONNECTING</code></dfn> (numeric value 0)</dt> <dd>The connection has not yet been established.</dd> - <dt><dfn id=dom-websocket-open title=dom-WebSocket-OPEN><code>OPEN</code></dfn> (numeric value 1)</dt> + <dt><dfn id="dom-websocket-open" title="dom-WebSocket-OPEN"><code>OPEN</code></dfn> (numeric value 1)</dt> <dd>The <span>Web Socket connection is established</span> and communication is possible.</dd> - <dt><dfn id=dom-websocket-closed title=dom-WebSocket-CLOSED><code>CLOSED</code></dfn> (numeric value 2)</dt> + <dt><dfn id="dom-websocket-closed" title="dom-WebSocket-CLOSED"><code>CLOSED</code></dfn> (numeric value 2)</dt> <dd>The connection has been closed or could not be opened.</dd> - </dl><p>When the object is created its <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> must be set to - <code title=dom-WebSocket-CONNECTING><a href=#dom-websocket-connecting>CONNECTING</a></code> (0). The + </dl><p>When the object is created its <code title="dom-WebSocket-readyState"><a href="#dom-websocket-readystate">readyState</a></code> must be set to + <code title="dom-WebSocket-CONNECTING"><a href="#dom-websocket-connecting">CONNECTING</a></code> (0). The steps executed when the constructor is invoked change this - attribute's value.<p>The <dfn id=dom-websocket-postmessage title=dom-WebSocket-postMessage><code>postMessage(<var title="">data</var>)</code></dfn> method transmits data using the - connection. If the connection is not established (<code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> is not <code title=dom-WebSocket-OPEN><a href=#dom-websocket-open>OPEN</a></code>), it must raise an + attribute's value.<p>The <dfn id="dom-websocket-postmessage" title="dom-WebSocket-postMessage"><code>postMessage(<var title="">data</var>)</code></dfn> method transmits data using the + connection. If the connection is not established (<code title="dom-WebSocket-readyState"><a href="#dom-websocket-readystate">readyState</a></code> is not <code title="dom-WebSocket-OPEN"><a href="#dom-websocket-open">OPEN</a></code>), it must raise an <code>INVALID_STATE_ERR</code> exception. If the connection - <em>is</em> established, then the user agent must <span>send <var title="">data</var> using the Web Socket</span>.<p>The <dfn id=dom-websocket-disconnect title=dom-WebSocket-disconnect><code>disconnect()</code></dfn> + <em>is</em> established, then the user agent must <span>send <var title="">data</var> using the Web Socket</span>.<p>The <dfn id="dom-websocket-disconnect" title="dom-WebSocket-disconnect"><code>disconnect()</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. Closing the connection 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 + must do nothing. Closing the connection 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>.<hr><p>The following are the <span>event handler attributes</span> that must be supported, as DOM attributes, by all objects implementing - the <code><a href=#websocket>WebSocket</a></code> interface:<table><thead><tr><th><span title="event handler attributes">event handler attribute</span> <th><span>Event handler event type</span> - <tbody><tr><td><dfn id=handler-websocket-onopen title=handler-WebSocket-onopen><code>onopen</code></dfn> <td> <code title=event-open>open</code> - <tr><td><dfn id=handler-websocket-onmessage title=handler-WebSocket-onmessage><code>onmessage</code></dfn> <td> <code title=event-message>message</code> - <tr><td><dfn id=handler-websocket-onclose title=handler-WebSocket-onclose><code>onclose</code></dfn> <td> <code title=event-close>close</code> - </table><h2 id=feedback-from-the-protocol><span class=secno>5 </span>Feedback from the protocol</h2><p>When the <i>Web Socket connection is established</i>, the user + the <code><a href="#websocket">WebSocket</a></code> interface:<table><thead><tr><th><span title="event handler attributes">event handler attribute</span> <th><span>Event handler event type</span> + <tbody><tr><td><dfn id="handler-websocket-onopen" title="handler-WebSocket-onopen"><code>onopen</code></dfn> <td> <code title="event-open">open</code> + <tr><td><dfn id="handler-websocket-onmessage" title="handler-WebSocket-onmessage"><code>onmessage</code></dfn> <td> <code title="event-message">message</code> + <tr><td><dfn id="handler-websocket-onclose" title="handler-WebSocket-onclose"><code>onclose</code></dfn> <td> <code title="event-close">close</code> + </table><h2 id="feedback-from-the-protocol"><span class="secno">5 </span>Feedback from the protocol</h2><p>When the <i>Web Socket connection is established</i>, the user agent must run the following steps:<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> + <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><span>Queue a task</span> to <span>fire a simple event</span> - named <code title=event-open>open</code> at the - <code><a href=#websocket>WebSocket</a></code> object.</p> + 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 - the <code>MessageEvent</code> interface, with the event name <code title=event-message>message</code>, which does not bubble, is - 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><a href=#websocket>WebSocket</a></code> object.<hr><p id=closeWebSocket>When the <i>Web Socket connection is - closed</i>, the <code title=dom-WebSocket-readyState><a href=#dom-websocket-readystate>readyState</a></code> attribute's value - must be changed to <code title=dom-WebSocket-CLOSED><a href=#dom-websocket-closed>CLOSED</a></code> + the <code>MessageEvent</code> interface, with the event name <code title="event-message">message</code>, which does not bubble, is + 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><a href="#websocket">WebSocket</a></code> object.<hr><p id="closeWebSocket">When the <i>Web Socket connection is + closed</i>, the <code title="dom-WebSocket-readyState"><a href="#dom-websocket-readystate">readyState</a></code> attribute's value + must be changed to <code title="dom-WebSocket-CLOSED"><a href="#dom-websocket-closed">CLOSED</a></code> (2), and the user agent must <span>queue a task</span> to <span>fire - a simple event</span> named <code title=event-close>close</code> at the - <code><a href=#websocket>WebSocket</a></code> object.<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 id=web-socket-task-source>Web Socket task - source</dfn>.<h3 id=garbage-collection><span class=secno>5.1 </span>Garbage collection</h3><p>A <code><a href=#websocket>WebSocket</a></code> object with an open connection must not + a simple event</span> named <code title="event-close">close</code> at the + <code><a href="#websocket">WebSocket</a></code> object.<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 id="web-socket-task-source">Web Socket task + source</dfn>.<h3 id="garbage-collection"><span class="secno">5.1 </span>Garbage collection</h3><p>A <code><a href="#websocket">WebSocket</a></code> object with an open connection must not be garbage collected if there are any event listeners registered for - <code title=event-message>message</code> events.<p>If a <code><a href=#websocket>WebSocket</a></code> object is garbage collected while its + <code title="event-message">message</code> events.<p>If a <code><a href="#websocket">WebSocket</a></code> object is garbage collected while its connection is still open, the user agent must <span>close the Web - Socket connection</span>.<h2 class=no-num id=references>References</h2><p class=big-issue>This section will be written in a future + Socket connection</span>.<h2 class="no-num" id="references">References</h2><p class="big-issue">This section will be written in a future draft.<!--XXX-->
Received on Wednesday, 22 April 2009 22:22:32 UTC