checkpoint
This commit is contained in:
@@ -1,26 +1,29 @@
|
||||
using Gameboard.ShogiUI.Sockets.Extensions;
|
||||
using Gameboard.ShogiUI.Sockets.Models;
|
||||
using Gameboard.ShogiUI.Sockets.Models;
|
||||
using Gameboard.ShogiUI.Sockets.Repositories;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Messages;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Socket.Types;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq;
|
||||
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 HTTP route.
|
||||
public class ListGamesHandler : IActionHandler
|
||||
{
|
||||
private readonly ISocketCommunicationManager communicationManager;
|
||||
private readonly IGameboardRepository repository;
|
||||
|
||||
public ListGamesHandler(
|
||||
ISocketCommunicationManager communicationManager,
|
||||
IGameboardRepository repository)
|
||||
{
|
||||
this.communicationManager = communicationManager;
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public async Task Handle(WebSocket socket, string json, string userName)
|
||||
public async Task Handle(string json, string userName)
|
||||
{
|
||||
var request = JsonConvert.DeserializeObject<ListGamesRequest>(json);
|
||||
var getGamesResponse = string.IsNullOrWhiteSpace(userName)
|
||||
@@ -33,11 +36,10 @@ namespace Gameboard.ShogiUI.Sockets.Managers.ClientActionHandlers
|
||||
|
||||
var response = new ListGamesResponse(ClientAction.ListGames)
|
||||
{
|
||||
Games = games
|
||||
Games = games.ToList()
|
||||
};
|
||||
|
||||
var serialized = JsonConvert.SerializeObject(response);
|
||||
await socket.SendTextAsync(serialized);
|
||||
await communicationManager.BroadcastToPlayers(response, userName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user