blob: 59ea02c20ebb4d87f87ad36595dd8013d7b9a5b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
using System.Collections.Concurrent;
namespace Agent.Core.Sessions;
public sealed class SessionStore
{
private readonly ConcurrentDictionary<Guid, AgentSession> _sessions = new();
public AgentSession Create()
{
while (true)
{
var session = new AgentSession(Guid.NewGuid());
if (_sessions.TryAdd(session.SessionId, session)) return session;
}
}
public bool TryGet(Guid sessionId, out AgentSession? session) => _sessions.TryGetValue(sessionId, out session);
}
|