Interface IScriptProbeAgent
Interface for all agents that control survey delivery within Sensus.
Namespace: Sensus.Probes.User.Scripts
Assembly: Sensus.Shared.NuGet.dll
Syntax
public interface IScriptProbeAgent
Properties
DeliveryInterval
Interval of time between successive queries regarding the delivery of surveys.
Declaration
Nullable<TimeSpan> DeliveryInterval { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.TimeSpan> | The delivery interval. |
DeliveryIntervalToleranceAfter
Tolerance for DeliveryInterval after the scheduled time, if doing so will increase the number of batched actions and thereby decrease battery consumption.
Declaration
Nullable<TimeSpan> DeliveryIntervalToleranceAfter { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.TimeSpan> | The delay tolerance before. |
DeliveryIntervalToleranceBefore
Tolerance for DeliveryInterval before the scheduled time, if doing so will increase the number of batched actions and thereby decrease battery consumption.
Declaration
Nullable<TimeSpan> DeliveryIntervalToleranceBefore { get; }
Property Value
Type | Description |
---|---|
System.Nullable<System.TimeSpan> | The delay tolerance before. |
Description
Readable description of the agent.
Declaration
string Description { get; }
Property Value
Type | Description |
---|---|
System.String | The description. |
Id
Identifier of the agent (unique within the project).
Declaration
string Id { get; }
Property Value
Type | Description |
---|---|
System.String | The identifier. |
Methods
DeliverSurveyNowAsync(IScript)
Asks the agent whether an IScript should be delivered at the present time as scheduled/triggered, or if the delivery should instead be deferred to a later date.
Declaration
Task<Tuple<bool, Nullable<DateTimeOffset>>> DeliverSurveyNowAsync(IScript script)
Parameters
Type | Name | Description |
---|---|---|
IScript | script | Script. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Tuple<System.Boolean, System.Nullable<System.DateTimeOffset>>> | A tuple indicating (bool) whether the survey should be delivered at the present time, and (DateTimeOffset?) if not, what time instead it should be delivered. For example:
|
InitializeAsync(ISensusServiceHelper, IProtocol)
Initializes the IScriptProbeAgent. This is called when the IProtocol associated with this IScriptProbeAgent is started.
Declaration
Task InitializeAsync(ISensusServiceHelper sensusServiceHelper, IProtocol protocol)
Parameters
Type | Name | Description |
---|---|---|
ISensusServiceHelper | sensusServiceHelper | A reference to the service helper, which provides access to the app's core functionality. |
IProtocol | protocol | A reference to the IProtocol associated with this IScriptProbeAgent. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
ObserveAsync(IDatum)
Asks the agent to observe an IDatum object that was generated by Sensus.
Declaration
Task ObserveAsync(IDatum datum)
Parameters
Type | Name | Description |
---|---|---|
IDatum | datum | Datum. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
ObserveAsync(IScript, ScriptState)
Asks the agent to observe a new state for an IScript.
Declaration
Task ObserveAsync(IScript script, ScriptState state)
Parameters
Type | Name | Description |
---|---|---|
IScript | script | Script. |
ScriptState | state | State. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
SetPolicyAsync(JObject)
Sets the survey policy of the current IScriptProbeAgent. This method will be called in the following situations:
- When a push notification arrives with a new policy.
- When the IScriptProbeAgent itself instructs the app to update the policy, through a call to UpdateScriptAgentPolicyAsync(CancellationToken).
In any case, the new policy will be passed to this method as a Newtonsoft.Json.Linq.JObject.
Declaration
Task SetPolicyAsync(JObject policy)
Parameters
Type | Name | Description |
---|---|---|
Newtonsoft.Json.Linq.JObject | policy | Policy. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |