EventSource interface is used to receive server-sent events. It connects to a server over HTTP and receives events in
text/event-stream format without closing the connection.
You can set the
event field). You can also call
addEventListener() to listen for events just like any other event source.
See Using server-sent events for further details.
||The state of the connection, must be one of
In addition to these exposed attributes, there are two internal attributes that are not exposed directly:
- reconnection time
- This is a time, in milliseconds, used to determine how long to wait after a failed attempt to connect before trying again.
- last event ID string
- This is initially the empty string; the server can send a message with the field name
idto set this value.
||The connection is being established.|
||The connection is open and dispatching events.|
||The connection is not being established, has been closed or there was a fatal error.|
Closes the connection, if any, and sets the
readyState attribute to
CLOSED. If the connection is already closed, the method does nothing.
Initializes the object for use from C++ code with the principal, script context, and owner window that should be used.
void init( in nsIPrincipal principal, in nsIScriptContext scriptContext, in nsPIDOMWindow ownerWindow, in DOMString url );
- The principal to use for the request. This must not be
- The script context to use for the request. May be
- The associated window for the request. May be
EventSource's URL. This must not be empty.
|Feature||Chrome||Firefox (Gecko)||Internet Explorer||Opera||Safari|
|EventSource support||9||6.0 (6.0)||?||11||5|
|Cross-Origin Resource Sharing
|Feature||Android||Firefox Mobile (Gecko)||IE Mobile||Opera Mobile||Safari Mobile|