using System.Threading; using System.Threading.Tasks; namespace RudderSdk.Core; /// Session of a scenario leaderboard node. public sealed class LeaderboardSession { internal LeaderboardSession(ScenarioNodeContext context) => Context = context; /// Underlying node context. public ScenarioNodeContext Context { get; } /// Node id. public string Id => Context.NodeId; /// Reads a typed value from the node data. public T Get(string key, T defaultValue = default!) => Context.Get(key, defaultValue); /// Advances the run through the onEnd handle. public Task EndAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onEnd", cancellationToken); /// Advances the run through the onEnd handle (fire-and-forget). public void End() => Context.Complete("onEnd"); /// Advances the run through the onRewardClaimed handle. public Task RewardClaimedAsync(CancellationToken cancellationToken = default) => Context.CompleteAsync("onRewardClaimed", cancellationToken); /// Advances the run through the onRewardClaimed handle (fire-and-forget). public void RewardClaimed() => Context.Complete("onRewardClaimed"); }