public async Task <OkResult> Index() { await _webSocketWrapper.ConnectWebSocket(); await _gameStarter.CreateGame(); await _gameStarter.JoinGame(Race.Terran); if (Game.Task == null || Game.Task.Status == TaskStatus.RanToCompletion) { Game.Task = _game.Run(); } return(Ok()); }
public async Task CallWebSocketAndSaveByteResponse() { var webSocketWrapper = new WebSocketWrapper(); await webSocketWrapper.ConnectWebSocket(); var connectionService = new ConnectionService(webSocketWrapper); var gameStarter = new GameStarter(connectionService); await gameStarter.CreateGame(); await gameStarter.JoinGame(Race.Terran); // Ensure game is underway so observation has juicy stuff await Task.Delay(5000); await connectionService.SendRequestAsync(new Request { Observation = new RequestObservation() }); //var bytes = await connectionService.ReceiveMessageAsync(CancellationToken.None); var response = await connectionService.ReceiveRequestAsync(); File.WriteAllText("../../../response.json", response.ToString()); }