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

@@ -3,7 +3,6 @@ using Gameboard.ShogiUI.Sockets.Repositories;
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages;
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
using Newtonsoft.Json;
using System.Net.WebSockets;
using System.Threading.Tasks;
namespace Gameboard.ShogiUI.Sockets.Managers.ClientActionHandlers
@@ -20,13 +19,9 @@ 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<JoinGameRequest>(json);
var response = new JoinGameResponse(ClientAction.JoinGame)
{
PlayerName = userName
};
var joinGameResponse = await gameboardRepository.PutJoinPublicSession(new PutJoinPublicSession
{
@@ -34,15 +29,20 @@ namespace Gameboard.ShogiUI.Sockets.Managers.ClientActionHandlers
SessionName = request.GameName
});
var response = new JoinGameResponse(ClientAction.JoinGame)
{
PlayerName = userName,
GameName = request.GameName
};
if (joinGameResponse.JoinSucceeded)
{
response.GameName = request.GameName;
await communicationManager.BroadcastToAll(response);
}
else
{
response.Error = "Game is full.";
await communicationManager.BroadcastToPlayers(response, userName);
}
await communicationManager.BroadcastToAll(response);
}
}
}