Skip to content

Commit

Permalink
[e] (0) Briefly show an example of using different event types in Eve…
Browse files Browse the repository at this point in the history
…ntSource.

Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=14094

git-svn-id: http://svn.whatwg.org/webapps@6645 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Oct 6, 2011
1 parent ec4eef8 commit f567bbf
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 4 deletions.
27 changes: 25 additions & 2 deletions complete.html
Expand Up @@ -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 &mdash; Last Updated 5 October 2011</h2>
<h2 class="no-num no-toc">Living Standard &mdash; 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>
Expand Down Expand Up @@ -79812,7 +79812,30 @@ <h4 id=server-sent-events-intro><span class=secno>11.2.1 </span>Introduction</h4

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>
Expand Down
27 changes: 25 additions & 2 deletions index
Expand Up @@ -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 &mdash; Last Updated 5 October 2011</h2>
<h2 class="no-num no-toc">Living Standard &mdash; 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>
Expand Down Expand Up @@ -79812,7 +79812,30 @@ data: has two lines.

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>
Expand Down
28 changes: 28 additions & 0 deletions source
Expand Up @@ -90328,6 +90328,34 @@ data: has two lines.

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
Expand Down

0 comments on commit f567bbf

Please sign in to comment.