Rework Client Config To Use Single URL
This commit is contained in:
parent
042671da91
commit
53fab11f88
@ -16,11 +16,8 @@ namespace qtc_net_client_2.ClientModel
|
|||||||
[JsonRequired]
|
[JsonRequired]
|
||||||
public bool MinimizeToTray { get; set; } = true;
|
public bool MinimizeToTray { get; set; } = true;
|
||||||
|
|
||||||
[JsonPropertyName("apiEndpoint")]
|
[JsonPropertyName("serverUrl")]
|
||||||
[JsonRequired]
|
[JsonRequired]
|
||||||
public string ApiEndpoint { get; set; } = "https://qtc.alanmoon.net/api";
|
public string ServerUrl { get; set; } = "https://qtc.alanmoon.net";
|
||||||
[JsonPropertyName("gatewayEndpoint")]
|
|
||||||
[JsonRequired]
|
|
||||||
public string GatewayEndpoint { get; set; } = "https://qtc.alanmoon.net/chat";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ namespace qtc_net_client_2
|
|||||||
guessTheNumber.Show();
|
guessTheNumber.Show();
|
||||||
break;
|
break;
|
||||||
case "TicTacToeGame":
|
case "TicTacToeGame":
|
||||||
TicTacToeGame ticTacToeGame = new TicTacToeGame(_apiService);
|
TicTacToeGame ticTacToeGame = new TicTacToeGame(_apiService, _config);
|
||||||
ticTacToeGame.Show();
|
ticTacToeGame.Show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ using QtCNETAPI.Models;
|
|||||||
using QtCNETAPI.Schema;
|
using QtCNETAPI.Schema;
|
||||||
using QtCNETAPI.Services.ApiService;
|
using QtCNETAPI.Services.ApiService;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using qtc_net_client_2.ClientModel;
|
||||||
|
|
||||||
namespace qtc_net_client_2
|
namespace qtc_net_client_2
|
||||||
{
|
{
|
||||||
@ -15,13 +16,15 @@ namespace qtc_net_client_2
|
|||||||
private GameRoom? CurrentRoom { get; set; }
|
private GameRoom? CurrentRoom { get; set; }
|
||||||
|
|
||||||
private IApiService _apiService;
|
private IApiService _apiService;
|
||||||
|
private Config _config;
|
||||||
private AudioService _audioService = new();
|
private AudioService _audioService = new();
|
||||||
|
|
||||||
private int WinCount { get; set; }
|
private int WinCount { get; set; }
|
||||||
private bool JackpotWon { get; set; } = false;
|
private bool JackpotWon { get; set; } = false;
|
||||||
public TicTacToeGame(IApiService apiService)
|
public TicTacToeGame(IApiService apiService, Config config)
|
||||||
{
|
{
|
||||||
_apiService = apiService;
|
_apiService = apiService;
|
||||||
|
_config = config;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
@ -30,7 +33,7 @@ namespace qtc_net_client_2
|
|||||||
{
|
{
|
||||||
// first, connect to the game hub
|
// first, connect to the game hub
|
||||||
GameHubConnection = new HubConnectionBuilder()
|
GameHubConnection = new HubConnectionBuilder()
|
||||||
.WithUrl("http://localhost:5268/tttgame", options =>
|
.WithUrl($"{_config.ServerUrl}/tttgame", options =>
|
||||||
{
|
{
|
||||||
options.AccessTokenProvider = () => Task.FromResult(_apiService.SessionToken)!;
|
options.AccessTokenProvider = () => Task.FromResult(_apiService.SessionToken)!;
|
||||||
})
|
})
|
||||||
|
@ -23,8 +23,7 @@ namespace qtc_net_client_2
|
|||||||
if(System.Diagnostics.Debugger.IsAttached)
|
if(System.Diagnostics.Debugger.IsAttached)
|
||||||
{
|
{
|
||||||
// use localhost
|
// use localhost
|
||||||
clientConfig.ApiEndpoint = "http://localhost:5268/api";
|
clientConfig.ServerUrl = "http://localhost:5268";
|
||||||
clientConfig.GatewayEndpoint = "http://localhost:5268/chat";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// find config file
|
// find config file
|
||||||
@ -53,8 +52,8 @@ namespace qtc_net_client_2
|
|||||||
|
|
||||||
// instantiate new ApiService and GatewayService for this session
|
// instantiate new ApiService and GatewayService for this session
|
||||||
// this will keep the gateway thread in the main thread (i think)
|
// this will keep the gateway thread in the main thread (i think)
|
||||||
IApiService api = new ApiService(clientConfig.ApiEndpoint);
|
IApiService api = new ApiService($"{clientConfig.ServerUrl}/api");
|
||||||
IGatewayService gateway = new GatewayService(clientConfig.GatewayEndpoint, api);
|
IGatewayService gateway = new GatewayService($"{clientConfig.ServerUrl}/chat", api);
|
||||||
|
|
||||||
// ping api
|
// ping api
|
||||||
var pingResult = await api.PingServerAsync();
|
var pingResult = await api.PingServerAsync();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user