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

Documentation EventSource by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See also:

Static variables

@:value(2)staticinlineread onlyCLOSED:Int = 2

@:value(0)staticinlineread onlyCONNECTING:Int = 0

@:value(1)staticinlineread onlyOPEN:Int = 1

Constructor

new(url:String, ?eventSourceInitDict:EventSourceInit)

Throws:

null

DOMError

Variables

onerror:Function

Is an EventHandler being called when an error occurs and the error event is dispatched on this object.

onmessage:Function

Is an EventHandler being called when a message event is received, that is when a message is coming from the source.

onopen:Function

Is an EventHandler being called when an open event is received, that is when the connection was just opened.

read onlyreadyState:Int

An unsigned short representing the state of the connection. Possible values are CONNECTING (0), OPEN (1), or CLOSED (2).

read onlyurl:String

A DOMString representing the URL of the source.

Methods

close():Void

Closes the connection, if any, and sets the readyState attribute to CLOSED. If the connection is already closed, the method does nothing.

Inherited Variables

Inherited Methods

Defined by EventTarget

@:value({ capture : false })addEventListener(type:String, listener:Function, capture:Bool = false):Void

@:value({ capture : false })addEventListener(type:String, listener:EventListener, capture:Bool = false, ?wantsUntrusted:Bool):Void

Throws:

null

DOMError

dispatchEvent(event:Event):Bool

Throws:

null

DOMError

@:value({ capture : false })removeEventListener(type:String, listener:Function, capture:Bool = false):Void

@:value({ capture : false })removeEventListener(type:String, listener:EventListener, capture:Bool = false):Void

Throws:

null

DOMError