Exemple #1
0
        private override Task OnDisconnectedAsync(Exception exception)
        {
            Game game = _pokerService.GetCurrentGame(Context.ConnectionId);

            if (game != null)
            {
                Player player = _pokerService.GetCurrentPlayer(Context.ConnectionId);
                game.Players.Remove(player);

                if (game.Players.Count == 0)
                {
                    _pokerService.DeleteGame(game);
                }
                else
                {
                    SendGameStateUpdate();
                }
            }

            _pokerService.CheckForStaleGames(); //Unrelated to this game, but safety check to avoid memory leak

            return(base.OnDisconnectedAsync(exception));
        }