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