示例#1
0
        public async Task RemovePlayerFromLobby(string lobbyId, byte index)
        {
            var settings = new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.All
            };

            // logic
            var(playerList, removedPlayer) = LobbyHandler.RemovePlayerFromLobby(lobbyId, index);

            // notify removed player
            await Clients.Group(Game.UniquePlayerGroup(lobbyId, index)).SendAsync("LeaveLobby");

            //await Groups.RemoveFromGroupAsync(Context.ConnectionId, lobbyId);
            await Clients.Group(lobbyId).SendAsync("ReceiveMessage", removedPlayer.InGameName, "I left the Lobby");

            await Clients.Group(lobbyId).SendAsync("PlayerListChanged", JsonConvert.SerializeObject(playerList, Formatting.Indented, settings));
        }