EventSource

EventSource

[13] EventSource は、遠隔DOM事象を受信するための物体が実装する DOM界面です。

仕様書

文脈

[66] いわゆるプッシュ型サーバーからクライアントへの情報伝達に使うことができます。

[67] しかし更新頻度が低ければポーリングでよく、高いか不定なら WebSocket が便利なので、 SSE はあまり出番もないかもしれません。

[68] 例えばチャットサーバーから任意のタイミングで発言を送信したいので、 SSE が使えそうに見えます。しかしクライアントからサーバーへも発言を送りたいので、 どうせなら同じ WebSocket の接続を使った方がよく、一方向の SSE を使う理由は薄いです。

EventSource コンストラクター

[73]

  1. [74] 文脈オブジェクト関連設定群オブジェクト大域オブジェクトEventSourceに、 弱い参照イベント源を追加します。 (unloading document cleanup steps で参照されます。)
  2. [75] イベント源を返します。

歴史

event-source 要素の登場

[14] はじめ、 event-source 要素として Ian Hickson により提案されていました。この提案は後に Web Applications 1.0 仕様書 (HTML5) に組み入れられました。

[93] HTML要素概説
要素名
event-source
日付
説明
Ian HicksonWebログで、 event-source を提案した。
出典

Working Draft 8 June 2004

WA1

[1] Web Applications 1.0 http://www.whatwg.org/specs/web-apps/current-work/#scs-server-sent

[92] HTML要素概説
要素名
event-source
日付
説明
Web Applications 1.0event-source がある。
出典

HTML5

[27] 2008年2月に大改訂がありましたが、その前の仕様は >>28 のような感じでした。

[28] HTML 5 ( 版) http://www.whatwg.org/specs/web-apps/2007-10-26/#server-sent-events

[21] Opera 9 以降で実装されています。 ニンテンドーDSiブラウザーでも使えます。

[2] Opera Web Chat http://oxzone.opera.com/webchat/ (名無しさん)

[3] Event Streaming to Web Browsers - Web Applications Blog - by Web Applications http://my.opera.com/WebApplications/blog/show.dml/438711

[19] Event Streaming to Web Browsers (Opera Software ASA 著, 版) http://labs.opera.com/news/2006/09/01/

[4] EarthQuakes Map Widget - Opera Widgets http://widgets.opera.com/widget/5178 (名無しさん 2006-09-09 03:28:34 +00:00)

[5] Bug 338583 – Add support for Server-Sent DOM Events (Remote Events) (2007-08-17 13:54:47 +09:00 版) https://bugzilla.mozilla.org/show_bug.cgi?id=338583

application/x-dom-event-stream から text/event-stream

[6] Hixie が Status を Being considered for removal に設定しているみたいです。 (名無しさん 2007-12-09 05:50:04 +00:00)

[7] >>6 大改訂があった結果、event-sourceLast call for comments鯖送信DOM事象の章は Working draft になっています。 (名無しさん 2008-02-23 10:28:51 +00:00)

[8] >>7 さっきの Ian Hickson#whatwg での発言によると、 削ろうと思ったけど残すべきという意見があって、 それがもっともだと思ったから削るのはやめたと。 (名無しさん 2008-02-23 10:41:26 +00:00)

[9] Re: several messages about <event-source> and related subjects (Ian Hickson <ian@...> 著, 版) http://permalink.gmane.org/gmane.org.w3c.whatwg.discuss/13321

[24] HTML5 Tracker ( 版) http://html5.org/tools/web-apps-tracker?from=1236&to=1238

[25] >>24 では大規模な変更があり、 MIME型application/x-dom-event-stream から text/event-stream に変更されました。

[98] [whatwg] several messages about <event-source> and related subjects, , https://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-February/056300.html

event-source から eventsource

[10] HTML5 で定義されていた event-source 要素は、 eventsource に改名されました。 >>26

[95] HTML要素概説
要素名
event-source
要素名
eventsource
日付
説明
HTML5event-sourceeventsource に改称された。
出典

eventsource 要素から EventSource 界面へ

[11] 以前から eventsource 要素要素である意味があるのか疑問視する意見がありましたが、 2009年2月に要素としては削除され、 EventSource DOM 界面となりました。

[12] IRC logs: freenode / #whatwg / 20090226 ( 版) http://krijnhoetmer.nl/irc-logs/whatwg/20090226#l-250

17:40 (hsivonen) Hixie: so what's the remaining selling point over Web Sockets? that you can feed EventSource from a regular HTTP server?

17:40 (Hixie) the only selling point over websocket that it's ever had is that it is compatible with CGI scripts

[15] Server-Sent Events ( 版) http://dev.w3.org/cvsweb/~checkout~/html5/eventsource/Overview.html?content-type=text/html;%20charset=utf-8

[16] Server-Sent Events ( 版) http://www.w3.org/TR/2009/WD-eventsource-20090423/

[18] IRC logs: freenode / #whatwg / 20100427 ( 版) http://krijnhoetmer.nl/irc-logs/whatwg/20100427#l-174

[97] HTML要素概説
要素名
eventsource
日付
説明
HTML5eventsource は削除され、 EventSource インターフェイスが追加された。
出典

テスト・ケース

[20] Index of /~wakaba/-temp/test/dom/eventsource ( 版) http://suika.fam.cx/~wakaba/-temp/test/dom/eventsource/

メモ

[29] Server-Sent Events ( ( 版)) http://www.w3.org/TR/2011/WD-eventsource-20110208/

[30] [whatwg] EventSource - Handling a charset in the content-type header ( ( 版)) http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-June/032120.html

[31] [whatwg] Enhancement request: change EventSource to allow cross-domain access ( ( 版)) http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-June/032152.html

[32] Server-Sent Events ( ( 版)) http://www.w3.org/TR/2011/WD-eventsource-20111020/

[33] Opera Desktop Team - Web Sockets enter the Opera House ( ( 版)) http://my.opera.com/desktopteam/blog/2010/10/11/websockets

[34] Web Applications 1.0 r6848 Require implementations to ignore all MIME type parameters on text/event-stream resourcesAffected topics: Server-Sent Events ( ( 版)) http://html5.org/tools/web-apps-tracker?from=6847&to=6848

[35] Server-Sent Events ( 版) http://www.w3.org/TR/2009/WD-eventsource-20091029/

[36] Server-Sent Events ( ( 版)) http://www.w3.org/TR/2012/WD-eventsource-20120426/

[37] [ietf-types] Registration for text/event-stream ( ( 版)) http://www.ietf.org/mail-archive/web/ietf-types/current/msg01713.html

[38] Server-Sent Events ( ( 版)) http://www.w3.org/TR/2012/WD-eventsource-20121023/

[39] Server-Sent Events ( ( 版)) http://www.w3.org/TR/2012/CR-eventsource-20121211/

[40] Server-Sent Events ( 版) http://www.w3.org/TR/2009/WD-eventsource-20091222/

[41] Server-Sent Events ( ( 版)) http://www.w3.org/TR/2011/WD-eventsource-20110310/

[42] IRC logs: freenode / #whatwg / 20130917 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20130917

[43] Web Applications 1.0 r3552 Include MIME type registration sections. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=3551&to=3552

[44] Web Applications 1.0 r8475 Make the EventSource processing model a mite more generic to allow other user agent types to implement this spec. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8474&to=8475

[45] MIX: Dropping exceptions for XHR and EventSource. · aac819b · w3c/webappsec ( ( 版)) https://github.com/w3c/webappsec/commit/aac819b28287e8fd3a9ebad2666336e2bc77a24b

[46] RE: [eventsource] Seeking status and plans ( (Zhang, Zhiqiang 著, 版)) http://lists.w3.org/Archives/Public/public-test-infra/2014OctDec/0009.html

[47] Server-Sent Events ( ( 版)) http://www.w3.org/TR/2014/PR-eventsource-20141209/

[49] Streaming | Flowdock API ( ( 版)) https://www.flowdock.com/api/streaming

[50] Server-Sent Events ( ( 版)) http://www.w3.org/TR/2015/REC-eventsource-20150203/

[51] Streaming | Flowdock API ( 版) https://www.flowdock.com/api/streaming

Event-Stream follows the HTML5 Server-Sent Events specification. Each event contains a JSON-encoded message.

[52] REST API - Firebase ( 版) https://www.firebase.com/docs/rest/api/#section-streaming

Firebase REST endpoints support the EventSource / Server-Sent Events protocol as well.

[53] 1156137 – EventSource only works with HTTP channels ( 版) https://bugzilla.mozilla.org/show_bug.cgi?id=1156137

[54] [whatwg] Server-sent events feedback ( ( 版)) http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-February/030205.html

[55] 25984 – EventSource should support RequestInfo ( 版) https://www.w3.org/Bugs/Public/show_bug.cgi?id=25984

[56] Integrate Fetch into HTML · whatwg/html@7c5555a ( 版) https://github.com/whatwg/html/commit/7c5555a16f2920c02244c10756bb2f1a11e87a22

[57] Allow user agents to fail a failed EventSource connection · whatwg/html@3970693 ( 版) https://github.com/whatwg/html/commit/3970693427240344dc09ae68cd21214fe3fc6622

[58] PSA: Change the Latest Editor's Drafts of WebStorage, WebWorkers, WebMessaging, Server-Sent Events and WebSockets (Xiaoqian Wu 著, 版) https://lists.w3.org/Archives/Public/public-webapps/2015OctDec/0099.html

[59] URLs are parsed and produce records · whatwg/html@30bc255 ( 版) https://github.com/whatwg/html/commit/30bc2557105ad62881ec9670f253febbc9761b44

[60] EventSource has no need to set Cache-Control · whatwg/html@6f47a53 ( 版) https://github.com/whatwg/html/commit/6f47a53c915ba001cb9e8f7d106a4dcab2a03f98

[61] JSON Mail Access Protocol Specification (JMAP) ( 版) http://jmap.io/spec.html

There are two mechanisms by which the client can receive the push events. The first is directly via a text/event-stream resource

[62] Make EventSource use the base URL of its global · whatwg/html@3175b53 ( 版) https://github.com/whatwg/html/commit/3175b53a7fab83a62fc1c5674e8356f720d2aa4a

[63] Move server-sent events IANA considerations to the index ( (momdo著, )) https://github.com/whatwg/html/commit/bb1e4e65145b670027de8562e427280a4aa85e94

[64] Server-Sent Eventsでtail -Fっぽいやつ - Qiita ( ()) http://qiita.com/usopyon/items/6067d3d249be7a5d2867

tail -Fっぽく、ファイルが更新されたらブラウザに差分をPUSHするスクリプトを書いてみました。

[65] Align Fetch's destination concept with changes in Fetch (sideshowbarker著, ) https://github.com/whatwg/html/commit/5e8f96a85d182d36c177db0d6fdde58b4ded86d4

[69] Set some MessageEvent's isTrusted attributes to true (domenic著, ) https://github.com/whatwg/html/commit/eecea4bf565a442e98c2ec98bf298d082d196282

[70] Specify the realm for the SSE MessageEvent (domenic著, ) https://github.com/whatwg/html/commit/91d19d647433203f1f319e2afe76e63ceae646ca

[71] Streaming | Flowdock API () https://www.flowdock.com/api/streaming

Event-Stream (text/event-stream)

Event-Stream follows the HTML5 Server-Sent Events specification. Each event contains a JSON-encoded message.

[72] Realtime messaging - Restdb.io (the team at restdb.io著, ) https://restdb.io/docs/realtime-messaging

RestDB.io can act as a Realtime messaging hub for your application. You can use the realtime API from web clients and servers, actually any client that can connect to your database using the HTTP EventSource API.

[76] RFC 8040 - RESTCONF Protocol () https://tools.ietf.org/html/rfc8040

event stream resource: a resource that represents an SSE

(Server-Sent Events) event stream. The content consists of text

using the media type "text/event-stream", as defined by the SSE

specification

[77] documentation/Streaming-API.md at master · tootsuite/documentation () https://github.com/tootsuite/documentation/blob/master/Using-the-API/Streaming-API.md

[78] EventSource: ignore IDs with U+0000 (annevk著, ) https://github.com/whatwg/html/commit/e0d4e9e5e8bf421793b77e0852fa00f55340b989

[79] [EventSource] Is Last-Event-ID header value allowed to contain any-char? · Issue #689 · whatwg/html () https://github.com/whatwg/html/issues/689

[80] Add an introductory API overview block for EventSource (sideshowbarker著, ) https://github.com/whatwg/html/commit/45364dd3f7eeca8387fadf2d7219a8f6c26c2d76

[81] Add a domintro block for EventSource interface by sideshowbarker · Pull Request #3173 · whatwg/html () https://github.com/whatwg/html/pull/3173

[82] Editorial: less continue after returning (annevk著, ) https://github.com/whatwg/html/commit/0d097af1acbeabe56a1b0d0c2e2f521eca4defa8

[83] "Return the new EventSource object, but continue..." · Issue #692 · whatwg/html () https://github.com/whatwg/html/issues/692

[84] Editorial: less continue after returning by annevk · Pull Request #3385 · whatwg/html () https://github.com/whatwg/html/pull/3385

[85] EventSource close · Issue #3380 · whatwg/html () https://github.com/whatwg/html/issues/3380

[86] Clarify if EventSource interface is enabled in Service Worker · Issue #3620 · whatwg/html () https://github.com/whatwg/html/issues/3620

[87] When to "fail the connection" of an EventSource? · Issue #3789 · whatwg/html () https://github.com/whatwg/html/issues/3789

[88] Memorandum of Understanding Between W3C and WHATWG () https://www.w3.org/2019/04/WHATWG-W3C-MOU.html

[89] データの取得  |  Firebase (, ) https://firebase.google.com/docs/database/rest/retrieve-data?hl=ja#section-rest-streaming

[90] Editorial: remove unnecessary parameter (jugglinmike, , ) https://github.com/whatwg/html/commit/f3f1f62ee16d7056bde8c2cffe1eebe81265a062

[91] Editorial: remove unnecessary parameter by jugglinmike · Pull Request #5132 · whatwg/html () https://github.com/whatwg/html/pull/5132