CREventSender

This class extends CRStateMachine

It is used to send events to identified clients who receive them by means of the HTML EventSource interface

Contstructor

CREventSender(config, clientRole)
Parameters
config
A CRConfig object, required
Configuration parameters and methods
clientRole
String, required
The role of the client ("controller" or "responder")

Properties

See also CRStateMachine properties

clientActive
Boolean, writeOnly
Indicates whether the client is active or not
clientId
String, writeOnly
The current clientId
accessToken
String, writeOnly
The current accessToken
partnerClientId
String, writeOnly
Identifies the client to which this sender will send events

Methods

See also CRStateMachine methods

Init()
Initiates dynamic variables and activates the object
genCrEvent(eventType, eventSubType = "", eventParams = [], buffered = false, logged = false, interceptable = true)
Generates a CREvent object, with sender and recipient properties assigned to the sender
Parameters
eventType
String, required
The event type
eventSubType
String, default = ""
Optional subtype, providing explanatory information not affecting event handling
eventParams
Array, default = []
An abitrary array of strings that can be converted to actual values using default ECMAScript string conversion. The strings must not contain the config.eventDataSplitChar character (comma by default).
buffered
Boolean, default = false
If true, the event will be saved if the client is offline and sent (if possible) when it becomes online.
logged
Boolean, default = false
If true the event will always be logged by the eventSender, even if not forwarded
interceptable
Boolean, default = true
If true, the event can be intercepted/modified by server-side interceptor functions
sendCrEvent(crEvent)
Sends a crEvent, ensuring a minimum delay of minCrEventDt millisecs between events.
Parameters
crEvent
A CREvent object, required
sendCrEventNow(crEvent)
Sends a crEvent immediately
Parameters
crEvent
A CREvent object, required

Events

See CRStateMachine events

States

ready
The sender has been assigned the required sender/recipient properties and is able to send events.
partnerRejected
The sender has been assigned required properties, but has been rejected by the assigned partner.
notReady
The sender has not been assigned the required sender/recipient properties and is not able to send events.