CRConfig
This class contains configuration properties and methods used by other classes.
Subclasses may add and override properties and methods as needed.
Contstructor
- __construct($appId, $resourceName, $appLogRoot, $appDataRoot, $crsSockRoot, $crsDataRoot)
-
Parameters
- $appId
- String, required
- Name of the current appId, e.g. "commtest" or "mathtrials"
- $resourceName
- String, required
- Name of the current resource, e.g. "clientid", "eventsource", "sendevent"
- $appLogRoot
- String, required
- Path to the directory used for logging
- $appDataRoot
- String, required
- Path to the directory used for data files
- $crsSockRoot
- String, required
- Path to the directory used for socket files
- $crsDataRoot
- String, required
- Path to the directory used for data files
Properties
- $resourceName
- String
- Name of the current resource, e.g. "clientid", "eventsource", "sendevent"
- initiated by the constructor
- $appLogRoot
- String
- Path to the directory used for logging
- initiated by the constructor
- $appDataRoot
- String
- Path to the directory used for data files
- initiated by the constructor
- String
- Path to the directory used for socket files
- initiated by the constructor
- $crsDataRoot
- String
- Path to the directory used for data files related to the current IP domain
- initiated by the constructor
- $socketAcceptDtSecs
- Integer, readonly, default = 10
- Max amount of secs before socket conditions are checked by a
CREventSource
- $maxPrevAliveDtSecs
- Integer, default = 25
- Max amount of secs allowed between alive events in a
CREventSource before the requesting client is considered inactive
- $sendEventRetryDtSecs
- Integer, default = 1
- Delay between attempts to establish connection to a socket by a CREventSender
- $sendEventMaxAttempts
- Integer, default = 4
- Max no of attempts to establish connection to a socket by a CREventSender
- $maxEventDataStrLength
- Integer, default = 8192
-
Max length of data strings that can be transmitted between a
CREventSender and a CREventSource
- $eventDataSplitChar
- String, default = ","
- Character used to split data elements in server-sent event data strings
Methods
- isAuthorized($clientRole, $accessToken) → Boolean
- Returns true if the $accessToken is authorized for the $clientRole
Parameters
- clientRole
- String, required
- The role of the sender client ("controller" or "responder")
- accessToken
- String, required
- A string containing the accessToken used to identify the requesting user and determine access rights
- acceptAtEventSender($crClient, $crEvent) → Boolean
- Returns true if the $crEvent is accepted for sending from the requesting $crClient
- It can also modify the event and perform various other actions
Parameters
- $crClient
- CRClient
- The requesting client
- $crEvent
- CREvent, required
- A crEvent
- acceptAtEventSource($crClient, $crEvent) → Boolean
- Returns true if the $crEvent is accepted for forwarding to the requesting $crClient
- It can also modify the event and perform various other actions
Parameters
- $crClient
- CRClient
- The requesting client
- $crEvent
- CREvent, required
- A crEvent
- isValidClientId($clientId) → Boolean
- Returns true if the $clientId is syntactically correct.
The default implementation requires a string consisting of 6 digits.
Parameters
- $clientId
- String, required
- A client id
- isValidClientRole($clientRole) → Boolean
- Returns true if the $clientRole is syntactically correct ("controller" or "responder").
Parameters
- $clientRole
- String, required
- A client role
- isValidAccessToken($accessToken) → Boolean
- Returns true if the $accessToken is syntactically correct.
The default implementation requires a non-empty string of printable Ascii characters, except space.
Parameters
- $accessToken
- String, required
- An access token
- logMsg($msg)
- Logs a message to a file corresponding to the current $resourceName in the assigned $appLogRoot directory
Parameters
- $msg
- String, required
- The message string to be logged