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:
@@ -1,17 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Shogi.Contracts.Api;
|
||||
|
||||
public class CreateGuestTokenResponse
|
||||
{
|
||||
public string UserId { get; }
|
||||
public string DisplayName { get; }
|
||||
public Guid OneTimeToken { get; }
|
||||
|
||||
public CreateGuestTokenResponse(string userId, string displayName, Guid oneTimeToken)
|
||||
{
|
||||
UserId = userId;
|
||||
DisplayName = displayName;
|
||||
OneTimeToken = oneTimeToken;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Shogi.Contracts.Api;
|
||||
|
||||
public class CreateSessionCommand
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace Shogi.Contracts.Api;
|
||||
|
||||
public class CreateTokenResponse
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string DisplayName { get; set; }
|
||||
public Guid OneTimeToken { get; set; }
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public class MovePieceCommand : IValidatableObject
|
||||
/// </summary>
|
||||
public MovePieceCommand()
|
||||
{
|
||||
To = string.Empty;
|
||||
this.To = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -20,9 +20,9 @@ public class MovePieceCommand : IValidatableObject
|
||||
/// </summary>
|
||||
public MovePieceCommand(string from, string to, bool isPromotion)
|
||||
{
|
||||
From = from;
|
||||
To = to;
|
||||
IsPromotion = isPromotion;
|
||||
this.From = from;
|
||||
this.To = to;
|
||||
this.IsPromotion = isPromotion;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -30,8 +30,8 @@ public class MovePieceCommand : IValidatableObject
|
||||
/// </summary>
|
||||
public MovePieceCommand(WhichPiece pieceFromHand, string to)
|
||||
{
|
||||
PieceFromHand = pieceFromHand;
|
||||
To = to;
|
||||
this.PieceFromHand = pieceFromHand;
|
||||
this.To = to;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -57,21 +57,21 @@ public class MovePieceCommand : IValidatableObject
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (PieceFromHand.HasValue && !string.IsNullOrWhiteSpace(From))
|
||||
if (this.PieceFromHand.HasValue && !string.IsNullOrWhiteSpace(this.From))
|
||||
{
|
||||
yield return new ValidationResult($"{nameof(PieceFromHand)} and {nameof(From)} are mutually exclusive properties.");
|
||||
yield return new ValidationResult($"{nameof(this.PieceFromHand)} and {nameof(this.From)} are mutually exclusive properties.");
|
||||
}
|
||||
if (PieceFromHand.HasValue && IsPromotion.HasValue)
|
||||
if (this.PieceFromHand.HasValue && this.IsPromotion.HasValue)
|
||||
{
|
||||
yield return new ValidationResult($"{nameof(PieceFromHand)} and {nameof(IsPromotion)} are mutually exclusive properties.");
|
||||
yield return new ValidationResult($"{nameof(this.PieceFromHand)} and {nameof(this.IsPromotion)} are mutually exclusive properties.");
|
||||
}
|
||||
if (!Regex.IsMatch(To, "[A-I][1-9]"))
|
||||
if (!Regex.IsMatch(this.To, "[A-I][1-9]"))
|
||||
{
|
||||
yield return new ValidationResult($"{nameof(To)} must be a valid board position, between A1 and I9");
|
||||
yield return new ValidationResult($"{nameof(this.To)} must be a valid board position, between A1 and I9");
|
||||
}
|
||||
if (!string.IsNullOrEmpty(From) && !Regex.IsMatch(From, "[A-I][1-9]"))
|
||||
if (!string.IsNullOrEmpty(this.From) && !Regex.IsMatch(this.From, "[A-I][1-9]"))
|
||||
{
|
||||
yield return new ValidationResult($"{nameof(From)} must be a valid board position, between A1 and I9");
|
||||
yield return new ValidationResult($"{nameof(this.From)} must be a valid board position, between A1 and I9");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
using Shogi.Contracts.Types;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Shogi.Contracts.Api;
|
||||
|
||||
public class ReadSessionsPlayerCountResponse
|
||||
{
|
||||
public IList<SessionMetadata> PlayerHasJoinedSessions { get; set; }
|
||||
public IList<SessionMetadata> AllOtherSessions { get; set; }
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Shogi.Contracts.Types;
|
||||
|
||||
namespace Shogi.Contracts.Api;
|
||||
|
||||
public class ReadSessionResponse
|
||||
{
|
||||
public Session Session { get; set; }
|
||||
}
|
||||
@@ -10,4 +10,8 @@
|
||||
<Description>Contains DTOs use for http requests to Shogi backend services.</Description>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Api\Queries\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using Shogi.Contracts.Types;
|
||||
|
||||
namespace Shogi.Contracts.Socket;
|
||||
|
||||
public interface ISocketMessage
|
||||
{
|
||||
SocketAction Action { get; }
|
||||
}
|
||||
|
||||
public class SocketResponse : ISocketMessage
|
||||
{
|
||||
public SocketAction Action { get; set; }
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using Shogi.Contracts.Types;
|
||||
|
||||
namespace Shogi.Contracts.Socket;
|
||||
|
||||
public class PlayerHasMovedMessage : ISocketMessage
|
||||
{
|
||||
public SocketAction Action { get; }
|
||||
public string SessionName { get; set; }
|
||||
/// <summary>
|
||||
/// The player that made the move.
|
||||
/// </summary>
|
||||
public string PlayerName { get; set; }
|
||||
|
||||
public PlayerHasMovedMessage()
|
||||
{
|
||||
Action = SocketAction.PieceMoved;
|
||||
SessionName = string.Empty;
|
||||
PlayerName = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Shogi.Contracts.Types;
|
||||
|
||||
namespace Shogi.Contracts.Socket;
|
||||
|
||||
public class SessionCreatedSocketMessage : ISocketMessage
|
||||
{
|
||||
public SocketAction Action => SocketAction.SessionCreated;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using Shogi.Contracts.Types;
|
||||
|
||||
namespace Shogi.Contracts.Socket;
|
||||
|
||||
public class SessionJoinedByPlayerSocketMessage : ISocketMessage
|
||||
{
|
||||
public SocketAction Action => SocketAction.SessionJoined;
|
||||
|
||||
public string SessionName { get; set; }
|
||||
|
||||
public SessionJoinedByPlayerSocketMessage(string sessionName)
|
||||
{
|
||||
SessionName = sessionName;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,20 @@
|
||||
namespace Shogi.Contracts.Types;
|
||||
using System;
|
||||
|
||||
namespace Shogi.Contracts.Types;
|
||||
|
||||
public class Session
|
||||
{
|
||||
public User Player1 { get; set; }
|
||||
public User? Player2 { get; set; }
|
||||
public string SessionName { get; set; }
|
||||
/// <summary>
|
||||
/// Email
|
||||
/// </summary>
|
||||
public string Player1 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Email. Null if no second player exists.
|
||||
/// </summary>
|
||||
public string? Player2 { get; set; }
|
||||
|
||||
public Guid SessionId { get; set; }
|
||||
|
||||
public BoardState BoardState { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
namespace Shogi.Contracts.Types
|
||||
using System;
|
||||
|
||||
namespace Shogi.Contracts.Types
|
||||
{
|
||||
public class SessionMetadata
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int PlayerCount { get; set; }
|
||||
}
|
||||
public class SessionMetadata
|
||||
{
|
||||
public Guid SessionId { get; set; }
|
||||
public string Player1 { get; set; } = string.Empty;
|
||||
public string Player2 { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Shogi.Contracts.Types
|
||||
{
|
||||
public enum SocketAction
|
||||
{
|
||||
SessionCreated,
|
||||
SessionJoined,
|
||||
PieceMoved
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
namespace Shogi.Contracts.Types;
|
||||
|
||||
public class User
|
||||
{
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// A display name for the user.
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public User(string id, string name)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user