Replace custom socket implementation with SignalR.

Replace MSAL and custom cookie auth with Microsoft.Identity.EntityFramework
Also some UI redesign to accommodate different login experience.
This commit is contained in:
2024-08-25 03:46:44 +00:00
parent d688afaeae
commit 51d234d871
172 changed files with 3857 additions and 4045 deletions

View File

@@ -1,41 +1,32 @@
using Shogi.Domain.ValueObjects;
namespace Shogi.Domain;
namespace Shogi.Domain.Aggregates;
public class Session
public class Session(Guid id, string player1Name)
{
public Session(
string name,
string player1Name)
{
Name = name;
Player1 = player1Name;
Board = new(BoardState.StandardStarting);
}
public Guid Id { get; } = id;
public string Name { get; }
public ShogiBoard Board { get; } = new(BoardState.StandardStarting);
public ShogiBoard Board { get; }
/// <summary>
/// The email of the player which created the session.
/// </summary>
public string Player1 { get; } = player1Name;
/// <summary>
/// The User.Id of the player which created the session.
/// </summary>
public string Player1 { get; }
/// <summary>
/// The email of the second player.
/// </summary>
public string? Player2 { get; private set; }
/// <summary>
/// The User.Id of the second player.
/// </summary>
public string? Player2 { get; private set; }
public void AddPlayer2(string player2Name)
{
if (this.Player2 != null) throw new InvalidOperationException("Player 2 already exists while trying to add a second player.");
if (this.Player1.Equals(player2Name, StringComparison.OrdinalIgnoreCase)) throw new InvalidOperationException("Player 2 must be different from Player 1");
this.Player2 = player2Name;
}
public void AddPlayer2(string player2Name)
{
if (Player2 != null) throw new InvalidOperationException("Player 2 already exists while trying to add a second player.");
if (Player1.Equals(player2Name, StringComparison.OrdinalIgnoreCase)) throw new InvalidOperationException("Player 2 must be different from Player 1");
Player2 = player2Name;
}
public bool IsSeated(string playerName)
{
return Player1 == playerName || Player2 == playerName;
}
public bool IsSeated(string playerName)
{
return this.Player1 == playerName || this.Player2 == playerName;
}
}