public void OnGameCheat(long gameLobbyID, GameCheat gameCheat) { var gameLobby = gameLobbyService.GetGameLobby(gameLobbyID); if (gameLobby == null) { return; } gameLobby.UseLobbyLock(() => { gameLobby.GameLogicController.StartTurn(OnTurnTimeout); if (gameCheat == null) { foreach (var gameUser in gameLobby.GetUsers()) { var gameState = gameLobby.GameLogicController.GetGameState(gameUser); var connection = userConnectionsService.GameConnectionService.GetConnection(gameUser); var apiObject = new GameCallCheat { GameState = new GetGameState(gameState), GameCheat = null }; gameHubContext.Clients.Client(connection).GameCallCheat(apiObject); } } else { foreach (var gameUser in gameLobby.GetUsers()) { var gameState = gameLobby.GameLogicController.GetGameState(gameUser); var connection = userConnectionsService.GameConnectionService.GetConnection(gameUser); var apiObject = new GameCallCheat { GameState = new GetGameState(gameState), GameCheat = new GetGameCheat(gameCheat) }; gameHubContext.Clients.Client(connection).GameCallCheat(apiObject); } } }); }
public static Task GameCallCheat(this IClientProxy hubConnection, GameCallCheat apiObject) { return(hubConnection.SendAsync(GameHubApiKeys.GameCallCheat, apiObject)); }