eventsource
This resource generates a text/event-stream consisting of server-sent events sent from other clients or the requesting client
The stream will allways be opened, but will be aborted if appropriate credentials have not been provided
This resource must not be subjected to any kind of buffering mechanism
Internal constants
- crConfig
- Configuration parameters and methods, including the current appId
Request parameters
- clientid
- Identifies the recipient client
- clientRole
- The role of the recipient client ("controller" or "responder")
- accessToken
- An URLEncoded string containing the accessToken used to identify the current user and determine access rights<./dd>
Response
A text/event-stream stream
Event handling protocol
Incoming events not listed below will be ignored
Incoming events from the connected client
These events must contain the pid of the senders current eventsource instance
Events from senders with a clientId, clientRole or eventSourcePid not matching the current instance will be ignored.
- alive
- A messageEvent signalling that the recipient client is alive. This event is used to keep the resource open when the client is not interacting with a partnerClient.
-
The eventSource should be closed when it has not received any events for
maxPrevAliveDtSecs millisecs.
- close
-
A messageEvent signalling that the event stream should close immediately. The eventsource should respond with a
closed event and then terminate. Closing this way is generally faster than just closing the eventStream using the JavaScript API.
Incoming events from other eventsource instances
Events from instances with a clientId or clientRole not matching the current instance will be ignored.
- release
-
A messageEvent signalling that another eventsource instance will take over the stream. The eventsource should respond with a
aborted event with subType
releasedByOther and the pid of the process that sent the release event, and then terminate. This event is used to handle situations where a competing client with the same clientId has been activated or that regular termination of an eventsource instance has been delayed so that the replacement instance has started.
Outgoing events to the requesting client
In addition to
open and
error events generated by the JavaScript
EventSource object, the following
message events are forwarded to the requesting client:
- hello
-
A messageEvent signalling that the event stream is active. This event must contain the pid of the current instance and all subsequent events must match this pid.
- alive
-
A messageEvent confirming that the eventsource has received an alive. This event is used to measure the alive roundtrip time.
- closed
-
A messageEvent confirming that the event stream has been closed. Must contain the current pid.
- aborted
- A messageEvent signalling that the event stream has been aborted by CRSocket software.
-
Must contain the current pid, and a (potentially empty) code indicating why the stream was aborted. If the abortion was caused by a
release event, it must also contain the pid of the releasing eventsource.
- shutdown
-
A messageEvent signalling that the eventsource instance is about to be shut down, typically due to server timeout. This event enables immediate reopening by the client without default delays.
- crEvent
- A messageEvent containing a crEvent, forwarded from another crSocket.
Incoming events from other clients
- crEvent
- A messageEvent containing a crEvent, received from another client
-
Only events from clients with a matching appId and complimentary client role will be forwarded to the recipient client.
If the interceptable property is true
it may be blocked or modified by the acceptAtEventSource function. This function may also respond with custom crEvents to the other client.
Outgoing events to other clients
- crEvent.reject
-
A messageEvent containing a crEvent with
eventType
reject
-
This event will be returned to the sender if a crEvent with
eventType
ping event was not forwarded
-
The eventSubType property may contain a code indicating why the event was rejected.