W3C home > Mailing lists > Public > public-html-diffs@w3.org > October 2011

SSE; hixie: Briefly show an example of using different event types in EventSource. (whatwg r6645)

From: poot <cvsmail@w3.org>
Date: Wed, 05 Oct 2011 20:25:44 -0400
To: public-html-diffs@w3.org
Message-Id: <E1RBbmS-0001nI-F5@jay.w3.org>
SSE; hixie: Briefly show an example of using different event types in
EventSource. (whatwg r6645)

http://dev.w3.org/cvsweb/html5/eventsource/Overview.html?r1=1.198&r2=1.199&f=h
http://html5.org/tools/web-apps-tracker?from=6644&to=6645

===================================================================
RCS file: /sources/public/html5/eventsource/Overview.html,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -d -r1.198 -r1.199
--- Overview.html	4 Oct 2011 23:37:09 -0000	1.198
+++ Overview.html	6 Oct 2011 00:25:33 -0000	1.199
@@ -215,7 +215,7 @@
 
    <h1>Server-Sent Events</h1>
    
-   <h2 class="no-num no-toc" id="editor-s-draft-4-october-2011">Editor's Draft 4 October 2011</h2>
+   <h2 class="no-num no-toc" id="editor-s-draft-6-october-2011">Editor's Draft 6 October 2011</h2>
    <dl><dt>Latest Published Version:</dt>
     <dd><a href="http://www.w3.org/TR/eventsource/">http://www.w3.org/TR/eventsource/</a></dd>
     <dt>Latest Editor's Draft:</dt>
@@ -323,7 +323,7 @@
   </dl><p>The W3C <a href="http://www.w3.org/2008/webapps/">Web Applications
   Working Group</a> is the W3C working group responsible for this
   specification's progress along the W3C Recommendation track.
-  This specification is the 4 October 2011 Editor's Draft.
+  This specification is the 6 October 2011 Editor's Draft.
   </p><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
@@ -364,7 +364,20 @@
 data: This is the second message, it
 data: has two lines.
 
-data: This is the third message.</pre><p>Event streams requests can be redirected using HTTP 301 and 307
+data: This is the third message.</pre><hr><p>Authors can separate events by using different event types. Here
+  is a stream that has two event types, "add" and "remove":<pre>event: add
+data: 73857293
+
+event: remove
+data: 2153
+
+event: add
+
+data: 113411</pre><p>The script to handle such a stream would look like this (where
+  <code title="">addHandler</code> and <code title="">removeHandler</code> are functions that take one argument,
+  the event):<pre>var source = new EventSource('updates.cgi');
+source.addEventListener('add', addHandler, false);
+source.addEventListener('remove', removeHandler, false);</pre><p>The default event type is "message".<hr><p>Event streams requests can be redirected using HTTP 301 and 307
   redirects as with normal HTTP requests. Clients will reconnect if
   the connection is closed; a client can be told to stop reconnecting
   using the HTTP 204 No Content response code.<p>Using this API rather than emulating it using
Received on Thursday, 6 October 2011 00:25:50 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 6 October 2011 00:25:52 GMT