logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class AchievementPlatformSyncPass

    Owns every conversation with the platform gateway on behalf of AchievementService: pushing an unlock outward, reporting progress under the configured step throttle, reading the account back, and retrying whatever the platform refused while it was offline.

    Inheritance
    object
    AchievementPlatformSyncPass
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Achievements.Application.Services
    Assembly: Serenity.Achievements.Application.dll
    Syntax
    public class AchievementPlatformSyncPass
    Remarks

    The offline queue is not a queue at all — it is the set of stored records whose PlatformSynced is false, so it survives a crash and a reinstall for free. Every call here is best-effort: a platform that refuses, throws, or simply never answers leaves the record unsynced and logs, and never propagates.

    Constructors

    AchievementPlatformSyncPass(IAchievementPlatformGateway, AchievementStoreAccess, IAchievementSettings, ILogService)

    Initializes a new instance of the AchievementPlatformSyncPass class.

    Declaration
    public AchievementPlatformSyncPass(IAchievementPlatformGateway gateway, AchievementStoreAccess store, IAchievementSettings settings, ILogService logService)
    Parameters
    Type Name Description
    IAchievementPlatformGateway gateway

    The platform gateway to mirror unlocks to.

    AchievementStoreAccess store

    The store whose sync flags this pass maintains.

    IAchievementSettings settings

    Achievement configuration, read for the timeout and push step.

    ILogService logService

    Logging service. May be null.

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when a required collaborator is null.

    Properties

    IsAvailable

    Whether the platform reported itself reachable at the last check.

    Declaration
    public bool IsAvailable { get; }
    Property Value
    Type Description
    bool

    Methods

    ClearAsync(CancellationToken)

    Clears every achievement on the platform account, but only when the project opted in through ClearPlatformOnReset. Never throws.

    Declaration
    public Task<bool> ClearAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    Token used to cancel the operation.

    Returns
    Type Description
    Task<bool>

    True when the platform was asked and accepted; false when it refused or was skipped.

    InitializeAsync(CancellationToken)

    Brings the platform session up. Never throws; reports whether the platform is usable.

    Declaration
    public Task<bool> InitializeAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    Token used to cancel the operation.

    Returns
    Type Description
    Task<bool>

    PushProgressAsync(AchievementDefinition, AchievementProgress, AchievementProgress, CancellationToken)

    Reports progress towards a progressive achievement, but only when the new value crossed the configured push step. Never throws.

    Declaration
    public Task PushProgressAsync(AchievementDefinition definition, AchievementProgress previous, AchievementProgress current, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    AchievementDefinition definition

    The achievement being advanced.

    AchievementProgress previous

    The progress before this change.

    AchievementProgress current

    The progress after this change.

    CancellationToken cancellationToken

    Token used to cancel the operation.

    Returns
    Type Description
    Task

    PushUnlockAsync(AchievementDefinition, AchievementUnlockRecord, CancellationToken)

    Pushes one unlock to the platform and persists the resulting sync flag. Returns the record as it now stands — updated when the platform accepted it, unchanged otherwise.

    Declaration
    public Task<AchievementUnlockRecord> PushUnlockAsync(AchievementDefinition definition, AchievementUnlockRecord record, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    AchievementDefinition definition

    The achievement that was unlocked.

    AchievementUnlockRecord record

    The stored unlock record to push.

    CancellationToken cancellationToken

    Token used to cancel the operation.

    Returns
    Type Description
    Task<AchievementUnlockRecord>

    QueryUnlockedAsync(CancellationToken)

    Reads back which achievements the platform account already carries. Never throws, and propagates the gateway's own answer rather than constructing one: the gateway is the only party that knows whether it actually reached the account, so this pass adds nothing but a deadline around the call and a translation of a timeout into the same "unreachable" the gateway would have reported itself.

    Declaration
    public Task<PlatformUnlockQueryResult> QueryUnlockedAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    Token used to cancel the operation.

    Returns
    Type Description
    Task<PlatformUnlockQueryResult>

    RetryPendingAsync(IEnumerable<KeyValuePair<AchievementDefinition, AchievementUnlockRecord>>, CancellationToken)

    Retries every record the platform has not accepted yet, and reports the ones that made it through so the caller can refresh its cache.

    Declaration
    public Task<IReadOnlyList<AchievementUnlockRecord>> RetryPendingAsync(IEnumerable<KeyValuePair<AchievementDefinition, AchievementUnlockRecord>> pendingRecords, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    IEnumerable<KeyValuePair<AchievementDefinition, AchievementUnlockRecord>> pendingRecords

    The unsynced records, paired with the definition each belongs to.

    CancellationToken cancellationToken

    Token used to cancel the operation.

    Returns
    Type Description
    Task<IReadOnlyList<AchievementUnlockRecord>>

    The records the platform accepted during this pass, in their persisted form.

    In this article
    © 2026 Serenity. All Rights Reserved