feat(battle-node): in-memory IBattleSessionStore + PendingBattle
This commit is contained in:
17
SVSim.BattleNode/Sessions/InMemoryBattleSessionStore.cs
Normal file
17
SVSim.BattleNode/Sessions/InMemoryBattleSessionStore.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace SVSim.BattleNode.Sessions;
|
||||
|
||||
public sealed class InMemoryBattleSessionStore : IBattleSessionStore
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, PendingBattle> _pending = new();
|
||||
|
||||
public void RegisterPending(PendingBattle battle) =>
|
||||
_pending[battle.BattleId] = battle;
|
||||
|
||||
public PendingBattle? TryGetPending(string battleId) =>
|
||||
_pending.TryGetValue(battleId, out var b) ? b : null;
|
||||
|
||||
public bool RemovePending(string battleId) =>
|
||||
_pending.TryRemove(battleId, out _);
|
||||
}
|
||||
Reference in New Issue
Block a user