Skip to main content

Class DataSendDispatcher

Shared helper that resolves IDataSendService with a bounded number of retries before enqueuing a payload, so a handler is never permanently stranded when the service is not yet registered.

public static class DataSendDispatcher

Inheritance​

Remarks​

This addresses service resolution only. Transport-level retries (network timeout and re-send attempts) are already handled inside the request layer via DataCollectionSettings.RequestTimeout and DataCollectionSettings.MaxRetryCount.

The service is normally registered in DataSender.Awake, but a handler whose end-of-scenario send fires during a scene transition may run before that registration completes. Retrying across a few frames covers that window without blocking the participant.

If the service still cannot be resolved after DEFAULT_RESOLVE_ATTEMPTS attempts, the callback is invoked anyway. This matches the pipeline's existing fail-open contract in DataSender.SendDataCoroutine, where the callback fires even when a request fails, so that a dead backend never traps a participant mid-session.

Fields​

DEFAULT_RESOLVE_ATTEMPTS​

Number of times to attempt resolving IDataSendService before giving up.

public const int DEFAULT_RESOLVE_ATTEMPTS = 5

Field Value​

int

DEFAULT_RETRY_DELAY​

Seconds to wait between resolution attempts.

public const float DEFAULT_RETRY_DELAY = 0.5

Field Value​

float

Methods​

EnqueueWithRetry(MonoBehaviour, string, string, string, Action)​

Enqueues a payload, retrying service resolution before falling back to the callback.

public static void EnqueueWithRetry(MonoBehaviour runner, string jsonName, string json, string source, Action callback)

Parameters​

NameTypeDescription
runnerMonoBehaviourThe MonoBehaviour used to host the retry coroutine.
jsonNamestringIdentifier for the data record.
jsonstringSerialised JSON payload.
sourcestringHandler name, used only for diagnostics.
callbackActionInvoked once the payload has been handed to the send pipeline, or once resolution has definitively failed. Always invoked exactly once.
  • Remarks
  • Fields
    • DEFAULT_RESOLVE_ATTEMPTS
    • DEFAULT_RETRY_DELAY
  • Methods
    • EnqueueWithRetry(MonoBehaviour, string, string, string, Action)