diff --git a/qtc-net-client-2/ClientModel/Config.cs b/qtc-net-client-2/ClientModel/Config.cs index 1b0fce0..0ec71f8 100644 --- a/qtc-net-client-2/ClientModel/Config.cs +++ b/qtc-net-client-2/ClientModel/Config.cs @@ -16,11 +16,8 @@ namespace qtc_net_client_2.ClientModel [JsonRequired] public bool MinimizeToTray { get; set; } = true; - [JsonPropertyName("apiEndpoint")] + [JsonPropertyName("serverUrl")] [JsonRequired] - public string ApiEndpoint { get; set; } = "https://qtc.alanmoon.net/api"; - [JsonPropertyName("gatewayEndpoint")] - [JsonRequired] - public string GatewayEndpoint { get; set; } = "https://qtc.alanmoon.net/chat"; + public string ServerUrl { get; set; } = "https://qtc.alanmoon.net"; } } diff --git a/qtc-net-client-2/Forms/Main.cs b/qtc-net-client-2/Forms/Main.cs index 500392b..c2a9723 100644 --- a/qtc-net-client-2/Forms/Main.cs +++ b/qtc-net-client-2/Forms/Main.cs @@ -323,7 +323,7 @@ namespace qtc_net_client_2 guessTheNumber.Show(); break; case "TicTacToeGame": - TicTacToeGame ticTacToeGame = new TicTacToeGame(_apiService); + TicTacToeGame ticTacToeGame = new TicTacToeGame(_apiService, _config); ticTacToeGame.Show(); break; } diff --git a/qtc-net-client-2/Forms/TicTacToeGame.cs b/qtc-net-client-2/Forms/TicTacToeGame.cs index 6cad4cc..9ca522c 100644 --- a/qtc-net-client-2/Forms/TicTacToeGame.cs +++ b/qtc-net-client-2/Forms/TicTacToeGame.cs @@ -6,6 +6,7 @@ using QtCNETAPI.Models; using QtCNETAPI.Schema; using QtCNETAPI.Services.ApiService; using System.Threading.Tasks; +using qtc_net_client_2.ClientModel; namespace qtc_net_client_2 { @@ -15,13 +16,15 @@ namespace qtc_net_client_2 private GameRoom? CurrentRoom { get; set; } private IApiService _apiService; + private Config _config; private AudioService _audioService = new(); private int WinCount { get; set; } private bool JackpotWon { get; set; } = false; - public TicTacToeGame(IApiService apiService) + public TicTacToeGame(IApiService apiService, Config config) { _apiService = apiService; + _config = config; InitializeComponent(); } @@ -30,7 +33,7 @@ namespace qtc_net_client_2 { // first, connect to the game hub GameHubConnection = new HubConnectionBuilder() - .WithUrl("http://localhost:5268/tttgame", options => + .WithUrl($"{_config.ServerUrl}/tttgame", options => { options.AccessTokenProvider = () => Task.FromResult(_apiService.SessionToken)!; }) diff --git a/qtc-net-client-2/Program.cs b/qtc-net-client-2/Program.cs index edbf47f..32bc449 100644 --- a/qtc-net-client-2/Program.cs +++ b/qtc-net-client-2/Program.cs @@ -23,8 +23,7 @@ namespace qtc_net_client_2 if(System.Diagnostics.Debugger.IsAttached) { // use localhost - clientConfig.ApiEndpoint = "http://localhost:5268/api"; - clientConfig.GatewayEndpoint = "http://localhost:5268/chat"; + clientConfig.ServerUrl = "http://localhost:5268"; } // find config file @@ -53,8 +52,8 @@ namespace qtc_net_client_2 // instantiate new ApiService and GatewayService for this session // this will keep the gateway thread in the main thread (i think) - IApiService api = new ApiService(clientConfig.ApiEndpoint); - IGatewayService gateway = new GatewayService(clientConfig.GatewayEndpoint, api); + IApiService api = new ApiService($"{clientConfig.ServerUrl}/api"); + IGatewayService gateway = new GatewayService($"{clientConfig.ServerUrl}/chat", api); // ping api var pingResult = await api.PingServerAsync();