Before changing Piece[,] to Dictionary<string,Piece>

This commit is contained in:
2021-07-26 06:28:56 -05:00
parent f8f779e84c
commit 178cb00253
73 changed files with 1537 additions and 1418 deletions

View File

@@ -0,0 +1,33 @@
using Gameboard.ShogiUI.Sockets.Models;
using System.Collections.Concurrent;
namespace Gameboard.ShogiUI.Sockets.Managers
{
public interface IActiveSessionManager
{
void Add(Session session);
Session? Get(string sessionName);
}
// TODO: Consider moving this class' functionality into the ConnectionManager class.
public class ActiveSessionManager : IActiveSessionManager
{
private readonly ConcurrentDictionary<string, Session> Sessions;
public ActiveSessionManager()
{
Sessions = new ConcurrentDictionary<string, Session>();
}
public void Add(Session session) => Sessions.TryAdd(session.Name, session);
public Session? Get(string sessionName)
{
if (Sessions.TryGetValue(sessionName, out var session))
{
return session;
}
return null;
}
}
}