50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using Gameboard.ShogiUI.Sockets.Repositories;
|
|
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Gameboard.ShogiUI.Sockets.Managers.ClientActionHandlers
|
|
{
|
|
public interface IJoinGameHandler
|
|
{
|
|
Task Handle(JoinGameRequest request, string userName);
|
|
}
|
|
public class JoinGameHandler : IJoinGameHandler
|
|
{
|
|
private readonly IGameboardRepository gameboardRepository;
|
|
private readonly ISocketCommunicationManager communicationManager;
|
|
public JoinGameHandler(
|
|
ISocketCommunicationManager communicationManager,
|
|
IGameboardRepository gameboardRepository)
|
|
{
|
|
this.gameboardRepository = gameboardRepository;
|
|
this.communicationManager = communicationManager;
|
|
}
|
|
|
|
public async Task Handle(JoinGameRequest request, string userName)
|
|
{
|
|
//var request = JsonConvert.DeserializeObject<JoinGameRequest>(json);
|
|
|
|
//var joinSucceeded = await gameboardRepository.PutJoinPublicSession(new PutJoinPublicSession
|
|
//{
|
|
// PlayerName = userName,
|
|
// SessionName = request.GameName
|
|
//});
|
|
|
|
//var response = new JoinGameResponse(ClientAction.JoinGame)
|
|
//{
|
|
// PlayerName = userName,
|
|
// GameName = request.GameName
|
|
//};
|
|
//if (joinSucceeded)
|
|
//{
|
|
// await communicationManager.BroadcastToAll(response);
|
|
//}
|
|
//else
|
|
//{
|
|
// response.Error = "Game is full.";
|
|
// await communicationManager.BroadcastToPlayers(response, userName);
|
|
//}
|
|
}
|
|
}
|
|
}
|