[html5] r6645 - [e] (0) Briefly show an example of using different event types in EventSource. F [...]
whatwg at whatwg.org
whatwg at whatwg.org
Wed Oct 5 17:22:32 PDT 2011
Author: ianh
Date: 2011-10-05 17:22:31 -0700 (Wed, 05 Oct 2011)
New Revision: 6645
Modified:
complete.html
index
source
Log:
[e] (0) Briefly show an example of using different event types in EventSource.
Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=14094
Modified: complete.html
===================================================================
--- complete.html 2011-10-05 23:30:00 UTC (rev 6644)
+++ complete.html 2011-10-06 00:22:31 UTC (rev 6645)
@@ -240,7 +240,7 @@
<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
- <h2 class="no-num no-toc">Living Standard — Last Updated 5 October 2011</h2>
+ <h2 class="no-num no-toc">Living Standard — Last Updated 6 October 2011</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
@@ -79812,7 +79812,30 @@
data: This is the third message.</pre>
- <p>Event streams requests can be redirected using HTTP 301 and 307
+ <hr><p>Authors can separate events by using different event types. Here
+ is a stream that has two event types, "add" and "remove":</p>
+
+ <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):</p>
+
+ <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".</p>
+
+ <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>
Modified: index
===================================================================
--- index 2011-10-05 23:30:00 UTC (rev 6644)
+++ index 2011-10-06 00:22:31 UTC (rev 6645)
@@ -240,7 +240,7 @@
<header class=head id=head><p><a class=logo href=http://www.whatwg.org/><img alt=WHATWG height=101 src=/images/logo width=101></a></p>
<hgroup><h1 class=allcaps>HTML</h1>
- <h2 class="no-num no-toc">Living Standard — Last Updated 5 October 2011</h2>
+ <h2 class="no-num no-toc">Living Standard — Last Updated 6 October 2011</h2>
</hgroup><dl><dt><strong>Web developer edition:</strong></dt>
<dd><strong><a href=http://developers.whatwg.org/>http://developers.whatwg.org/</a></strong></dd>
<dt>Multiple-page version:</dt>
@@ -79812,7 +79812,30 @@
data: This is the third message.</pre>
- <p>Event streams requests can be redirected using HTTP 301 and 307
+ <hr><p>Authors can separate events by using different event types. Here
+ is a stream that has two event types, "add" and "remove":</p>
+
+ <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):</p>
+
+ <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".</p>
+
+ <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>
Modified: source
===================================================================
--- source 2011-10-05 23:30:00 UTC (rev 6644)
+++ source 2011-10-06 00:22:31 UTC (rev 6645)
@@ -90328,6 +90328,34 @@
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":</p>
+
+ <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):</p>
+
+ <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".</p>
+
+ <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
More information about the Commit-Watchers
mailing list