Files
Shogi/Gameboard.ShogiUI.Sockets/Models/Session.cs

35 lines
897 B
C#

using Newtonsoft.Json;
using System.Collections.Concurrent;
using System.Net.WebSockets;
namespace Gameboard.ShogiUI.Sockets.Models
{
public class Session
{
// TODO: Separate subscriptions to the Session from the Session.
[JsonIgnore] public ConcurrentDictionary<string, WebSocket> Subscriptions { get; }
public string Name { get; }
public string Player1 { get; }
public string? Player2 { get; private set; }
public bool IsPrivate { get; }
public Shogi Shogi { get; }
public Session(string name, bool isPrivate, Shogi shogi, string player1, string? player2 = null)
{
Subscriptions = new ConcurrentDictionary<string, WebSocket>();
Name = name;
Player1 = player1;
Player2 = player2;
IsPrivate = isPrivate;
Shogi = shogi;
}
public void SetPlayer2(string userName)
{
Player2 = userName;
}
}
}