Module eventsource
Server-sent events (HTML EventSource) and the MessageEvent members that are not plain payload. Messages arrive as "message" (or named) events: data in Event_data, the last event id in Event_text.
Exposed to: Window. Source: api/eventsource.widl.
Odin: import "wren:eventsource".
Types
handle EventSource : Object
Checked by the browser on every call (lookup_EventSource).
enum EventSourceState : i32
EventSource.readyState
| member | value | |
|---|---|---|
Connecting | 0 | |
Open | 1 | |
Closed | 2 |
Functions
EventSource_create
EventSource EventSource_create(string url, bool with_credentials = false) raisesnew EventSource(url, {withCredentials}). Syntax for an invalid URL.
Odin: eventsource.create.
Raises: returns an Error (see web).
Host: EventSource_create :: proc(c: ^Call, url: string, with_credentials: bool) -> (u64, Api_Error)
EventSource_readyState
EventSourceState EventSource_readyState(EventSource source)Odin: eventsource.readyState.
Host: EventSource_readyState :: proc(c: ^Call, source: Api_EventSource) -> Api_EventSourceState
EventSource_url
string EventSource_url(EventSource source)Odin: eventsource.url.
Host: EventSource_url :: proc(c: ^Call, source: Api_EventSource) -> string
EventSource_withCredentials
bool EventSource_withCredentials(EventSource source)Odin: eventsource.withCredentials.
Host: EventSource_withCredentials :: proc(c: ^Call, source: Api_EventSource) -> bool
EventSource_close
void EventSource_close(EventSource source)source.close()
Odin: eventsource.close.
Host: EventSource_close :: proc(c: ^Call, source: Api_EventSource)
MessageEvent_origin
string MessageEvent_origin(Event event)MessageEvent.origin
Host: MessageEvent_origin :: proc(c: ^Call, event: Api_Event) -> string
MessageEvent_lastEventId
string MessageEvent_lastEventId(Event event)MessageEvent.lastEventId ("" for messages that do not come from an EventSource).
Host: MessageEvent_lastEventId :: proc(c: ^Call, event: Api_Event) -> string