36 lines
813 B
C#
36 lines
813 B
C#
using Gameboard.ShogiUI.BoardState;
|
|
using System.Collections.Concurrent;
|
|
|
|
namespace Gameboard.ShogiUI.Sockets.Managers
|
|
{
|
|
public interface IBoardManager
|
|
{
|
|
void Add(string sessionName, ShogiBoard board);
|
|
ShogiBoard Get(string sessionName);
|
|
}
|
|
|
|
public class BoardManager : IBoardManager
|
|
{
|
|
private readonly ConcurrentDictionary<string, ShogiBoard> Boards;
|
|
|
|
public BoardManager()
|
|
{
|
|
Boards = new ConcurrentDictionary<string, ShogiBoard>();
|
|
}
|
|
|
|
public void Add(string sessionName, ShogiBoard board) => Boards.TryAdd(sessionName, board);
|
|
|
|
public ShogiBoard Get(string sessionName)
|
|
{
|
|
if (Boards.TryGetValue(sessionName, out var board))
|
|
return board;
|
|
return null;
|
|
}
|
|
|
|
public string GetBoardState()
|
|
{
|
|
return string.Empty;
|
|
}
|
|
}
|
|
}
|