From a4eb4d2b8843a805653533550c377d83106256d9 Mon Sep 17 00:00:00 2001 From: Michele Scandura Date: Thu, 23 Sep 2021 15:43:27 +0100 Subject: [PATCH 1/2] smal fixes --- Sledgemapper.Api/Commands/DeleteTileCommand.cs | 3 ++- Sledgemapper.Api/Controllers/MapController.cs | 7 +++++++ Sledgemapper.Api/Hubs/SledgemapperHub.cs | 16 ++++++++++++++-- Sledgemapper/CommunicationManager.cs | 2 +- Sledgemapper/UI/LoginRegisterWindow.Custom.cs | 2 +- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Sledgemapper.Api/Commands/DeleteTileCommand.cs b/Sledgemapper.Api/Commands/DeleteTileCommand.cs index e55f1dc..bfc2d31 100644 --- a/Sledgemapper.Api/Commands/DeleteTileCommand.cs +++ b/Sledgemapper.Api/Commands/DeleteTileCommand.cs @@ -1,3 +1,4 @@ +using System; using Sledgemapper.Shared.Entities; namespace Sledgemapper.Api.Commands @@ -6,7 +7,7 @@ namespace Sledgemapper.Api.Commands { public Tile Tile { get; private set; } - public DeleteTileCommand(string sessionName, Tile tile, string userId) : base(sessionName, userId) + public DeleteTileCommand(Guid campaign, Guid mapName, Tile tile, string userId) : base(campaign, mapName, userId) { Tile = tile; } diff --git a/Sledgemapper.Api/Controllers/MapController.cs b/Sledgemapper.Api/Controllers/MapController.cs index 683f84a..361a9a8 100644 --- a/Sledgemapper.Api/Controllers/MapController.cs +++ b/Sledgemapper.Api/Controllers/MapController.cs @@ -40,6 +40,13 @@ namespace Sledgemapper.Api.Controllers await _mediator.Send(new DeleteNoteCommand(campaign, mapName, note, UserId)); } + + [HttpDelete("tile")] + public async Task Delete(Guid campaign, Guid mapName, [FromBody] Tile tile) + { + await _mediator.Send(new DeleteTileCommand(campaign, mapName, tile, UserId)); + } + [HttpGet] public async Task Get(Guid campaign, Guid mapName) { diff --git a/Sledgemapper.Api/Hubs/SledgemapperHub.cs b/Sledgemapper.Api/Hubs/SledgemapperHub.cs index 847e221..d2668ce 100644 --- a/Sledgemapper.Api/Hubs/SledgemapperHub.cs +++ b/Sledgemapper.Api/Hubs/SledgemapperHub.cs @@ -166,9 +166,21 @@ namespace Sledgemapper.Api.Hubs foreach (var userSession in userSessions) { var session = _dbContext.Sessions.FirstOrDefault(m => m.SessionId == userSession.SessionId); + if (session != null) + { + + try + { + await Clients.Group(session.SessionId.ToString()).RemovePlayer(new Player { UserId = userId }); //send remove player + } + catch (Exception e) + { + Console.WriteLine(e); + + } + _dbContext.SessionUsers.Remove(userSession); + } - await Clients.Group(session.SessionName).RemovePlayer(new Player { UserId = userId }); //send remove player - _dbContext.SessionUsers.Remove(userSession); } } await _dbContext.SaveChangesAsync(); diff --git a/Sledgemapper/CommunicationManager.cs b/Sledgemapper/CommunicationManager.cs index 36adb4b..52bdd5d 100644 --- a/Sledgemapper/CommunicationManager.cs +++ b/Sledgemapper/CommunicationManager.cs @@ -35,7 +35,7 @@ namespace Sledgemapper _queue = new ChannelsQueue(Messenger); #if DEBUG var baseAddress = "http://localhost:5000"; - baseAddress = "http://hub.michelescandura.com:5001"; + //baseAddress = "http://hub.michelescandura.com:5001"; #else var baseAddress = "http://hub.michelescandura.com:5001"; #endif diff --git a/Sledgemapper/UI/LoginRegisterWindow.Custom.cs b/Sledgemapper/UI/LoginRegisterWindow.Custom.cs index de7d04e..73dee30 100644 --- a/Sledgemapper/UI/LoginRegisterWindow.Custom.cs +++ b/Sledgemapper/UI/LoginRegisterWindow.Custom.cs @@ -21,7 +21,7 @@ namespace Sledgemapper.UI _messenger = messenger; #if DEBUG - TxtEmail.Text = "michele.scandura@sloutlook.com"; + TxtEmail.Text = "michele.scandura@outlook.com"; TxtPassword.Text = "slePharland!79"; #endif From 4d591319054c361533c042e14b0bfb485e8931e1 Mon Sep 17 00:00:00 2001 From: Michele Scandura Date: Thu, 23 Sep 2021 15:44:56 +0100 Subject: [PATCH 2/2] another small fix --- Sledgemapper.Api/Hubs/SledgemapperHub.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sledgemapper.Api/Hubs/SledgemapperHub.cs b/Sledgemapper.Api/Hubs/SledgemapperHub.cs index d2668ce..9484d99 100644 --- a/Sledgemapper.Api/Hubs/SledgemapperHub.cs +++ b/Sledgemapper.Api/Hubs/SledgemapperHub.cs @@ -171,12 +171,11 @@ namespace Sledgemapper.Api.Hubs try { - await Clients.Group(session.SessionId.ToString()).RemovePlayer(new Player { UserId = userId }); //send remove player + await Clients.GroupExcept(session.SessionId.ToString(), new List { Context.ConnectionId }).RemovePlayer(new Player { UserId = userId }); //send remove player } catch (Exception e) { Console.WriteLine(e); - } _dbContext.SessionUsers.Remove(userSession); }