Skip to main content

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​

NameTypeDescription
namestringIdentifier for the data record (e.g., participant ID + scene name).
datastringSerialised JSON string to transmit.
callbackActionInvoked 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​

NameTypeDescription
namestringIdentifier for the data record.
datastringSerialised JSON string to transmit.
callbackActionInvoked after this specific payload completes or fails.
methodRequestMethodTransport method to use for this payload; overrides the project default.
  • Remarks
  • Methods
    • EnqueueData(string, string, Action)
    • EnqueueData(string, string, Action, RequestMethod)