Class DataSender
A service that serialises outbound study data into a FIFO queue and dispatches each payload sequentially via the configured IRequestFactory transport.
public class DataSender : MonoBehaviour, IDataSendService, IUnityGameService
Inheritance
Implements
Remarks
Callers (primarily the analysis pipeline after a scene ends) call Action) and immediately receive control back — no blocking. The queue ensures that even when several scene-end snapshots arrive in rapid succession, only one HTTP request or file write is in-flight at a time.
Methods
EnqueueData(string, string, Action)
Enqueues a named JSON payload using the project-wide default transport configured in
DataCollectionSettings.
public void EnqueueData(string name, string data, Action callback)
Parameters
| Name | Type | Description |
|---|---|---|
name | string | Identifier for the data record (e.g., participant ID + scene name). |
data | string | Serialised JSON string to transmit. |
callback | Action | Invoked after the send operation completes (or fails), regardless of success, so callers can release resources or advance the analysis pipeline. |
Remarks
Delegates to RequestMethod) with
the method resolved from DataCollectionSettings.instance.Method.
EnqueueData(string, string, Action, RequestMethod)
Enqueues a named JSON payload to be sent via the specified transport method, then starts the send coroutine if it is not already running.
public void EnqueueData(string name, string data, Action callback, RequestMethod method)
Parameters
| Name | Type | Description |
|---|---|---|
name | string | Identifier for the data record. |
data | string | Serialised JSON string to transmit. |
callback | Action | Invoked after this specific payload completes or fails. |
method | RequestMethod | Transport method to use for this payload; overrides the project default. |