before deleting Rules
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Gameboard.ShogiUI.Sockets.Repositories;
|
||||
using Gameboard.ShogiUI.Sockets.Managers;
|
||||
using Gameboard.ShogiUI.Sockets.Repositories;
|
||||
using Gameboard.ShogiUI.Sockets.Repositories.RepositoryManagers;
|
||||
using Gameboard.ShogiUI.Sockets.ServiceModels.Api.Messages;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -14,17 +15,20 @@ namespace Gameboard.ShogiUI.Sockets.Controllers
|
||||
public class GameController : ControllerBase
|
||||
{
|
||||
private readonly IGameboardRepositoryManager manager;
|
||||
private readonly ISocketCommunicationManager communicationManager;
|
||||
private readonly IGameboardRepository repository;
|
||||
|
||||
public GameController(
|
||||
IGameboardRepository repository,
|
||||
IGameboardRepositoryManager manager)
|
||||
IGameboardRepositoryManager manager,
|
||||
ISocketCommunicationManager communicationManager)
|
||||
{
|
||||
this.manager = manager;
|
||||
this.communicationManager = communicationManager;
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
[Route("JoinCode")]
|
||||
[HttpPost("JoinCode")]
|
||||
public async Task<IActionResult> PostGameInvitation([FromBody] PostGameInvitation request)
|
||||
{
|
||||
var userName = HttpContext.User.Claims.First(c => c.Type == "preferred_username").Value;
|
||||
@@ -41,7 +45,7 @@ namespace Gameboard.ShogiUI.Sockets.Controllers
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[Route("GuestJoinCode")]
|
||||
[HttpPost("GuestJoinCode")]
|
||||
public async Task<IActionResult> PostGuestGameInvitation([FromBody] PostGuestGameInvitation request)
|
||||
{
|
||||
|
||||
@@ -57,5 +61,26 @@ namespace Gameboard.ShogiUI.Sockets.Controllers
|
||||
return new UnauthorizedResult();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Use JWT tokens for guests so they can authenticate and use API routes, too.
|
||||
//[Route("")]
|
||||
//public async Task<IActionResult> PostSession([FromBody] PostSession request)
|
||||
//{
|
||||
// var model = new Models.Session(request.Name, request.IsPrivate, request.Player1, request.Player2);
|
||||
// var success = await repository.CreateSession(model);
|
||||
// if (success)
|
||||
// {
|
||||
// var message = new ServiceModels.Socket.Messages.CreateGameResponse(ServiceModels.Socket.Types.ClientAction.CreateGame)
|
||||
// {
|
||||
// Game = model.ToServiceModel(),
|
||||
// PlayerName =
|
||||
// }
|
||||
// var task = request.IsPrivate
|
||||
// ? communicationManager.BroadcastToPlayers(response, userName)
|
||||
// : communicationManager.BroadcastToAll(response);
|
||||
// return new CreatedResult("", null);
|
||||
// }
|
||||
// return new ConflictResult();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user