Skip to content
Permalink
Browse files

[e] (0) Briefly show an example of using different event types in Eve…

…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 f567bbf142aec94c4b6a82ffb908545dfb6537c3
Showing with 78 additions and 4 deletions.
  1. +25 −2 complete.html
  2. +25 −2 index
  3. +28 −0 source

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

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>
27 index

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

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>
28 source

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

0 comments on commit f567bbf

Please sign in to comment.
You can’t perform that action at this time.