checkpoint

This commit is contained in:
2021-02-23 18:03:23 -06:00
parent 8d79c75616
commit f644795cd3
38 changed files with 1451 additions and 177 deletions

View File

@@ -1,15 +1,15 @@
using Gameboard.Shogi.Api.ServiceModels.Messages;
using Gameboard.ShogiUI.Sockets.Extensions;
using Gameboard.ShogiUI.Sockets.Repositories;
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages;
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System.Net.WebSockets;
using System.Threading.Tasks;
namespace Gameboard.ShogiUI.Sockets.Managers.ClientActionHandlers
{
// TODO: This doesn't need to be a socket action.
// It can be an API route and still tell socket connections about the new session.
public class CreateGameHandler : IActionHandler
{
private readonly ILogger<CreateGameHandler> logger;
@@ -26,13 +26,13 @@ namespace Gameboard.ShogiUI.Sockets.Managers.ClientActionHandlers
this.communicationManager = communicationManager;
}
public async Task Handle(WebSocket socket, string json, string userName)
public async Task Handle(string json, string userName)
{
var request = JsonConvert.DeserializeObject<CreateGameRequest>(json);
var postSessionResponse = await repository.PostSession(new PostSession
{
SessionName = request.GameName,
PlayerName = userName, // TODO : Investigate if needed by UI
PlayerName = userName,
IsPrivate = request.IsPrivate
});
@@ -53,9 +53,7 @@ namespace Gameboard.ShogiUI.Sockets.Managers.ClientActionHandlers
if (request.IsPrivate)
{
var serialized = JsonConvert.SerializeObject(response);
logger.LogInformation("Response to {0} \n{1}\n", userName, serialized);
await socket.SendTextAsync(serialized);
await communicationManager.BroadcastToPlayers(response, userName);
}
else
{