chore(core): split up interfaces/helpers/models
This commit is contained in:
parent
1e693cabc2
commit
5f927ad66f
|
|
@ -43,6 +43,6 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\Kiseki.Launcher\*.cs" />
|
||||
<Compile Include="..\Kiseki.Launcher\**\*.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
@ -9,37 +9,37 @@ namespace Kiseki.Launcher
|
|||
public class Controller
|
||||
{
|
||||
private readonly string BaseURL;
|
||||
private readonly string JoinScriptURL;
|
||||
private readonly string Ticket;
|
||||
private IDictionary<string, string> Arguments = new Dictionary<string, string>();
|
||||
|
||||
public event EventHandler<string>? PageHeadingChanged;
|
||||
public event EventHandler<int>? ProgressBarChanged;
|
||||
public event EventHandler<ProgressBarState>? ProgressBarStateChanged;
|
||||
public event EventHandler? Launched;
|
||||
|
||||
public Controller(string BaseURL, string[] Arguments)
|
||||
public static readonly HttpClient HttpClient = new();
|
||||
|
||||
public Controller(string baseURL, string[] args)
|
||||
{
|
||||
this.BaseURL = BaseURL;
|
||||
BaseURL = baseURL;
|
||||
|
||||
// TODO: handle these more gracefully
|
||||
if (Arguments.Length != 0 || Arguments[0] != "launch")
|
||||
if (args.Length > 0)
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
// TODO: handle these more gracefully
|
||||
|
||||
if (!Helpers.IsBase64String(Arguments[0]))
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
if (!Helpers.Base64.IsBase64String(args[0]))
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
string payload = Helpers.ConvertBase64ToString(Arguments[0]);
|
||||
if (payload.Split("|").Length != 2) // joinscripturl, ticket; TODO: this will also include launchmode (ide/play)
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
string payload = Helpers.Base64.ConvertBase64ToString(args[0]);
|
||||
if (payload.Split("|").Length != 2) // joinscripturl, ticket; TODO: this will also include launchmode (ide/play) & other stuff
|
||||
{
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
JoinScriptURL = payload.Split("|")[0];
|
||||
Ticket = payload.Split("|")[1];
|
||||
Arguments["JoinScriptURL"] = payload.Split("|")[0];
|
||||
Arguments["Ticket"] = payload.Split("|")[1];
|
||||
}
|
||||
}
|
||||
|
||||
public async void Start()
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
using System.Text;
|
||||
|
||||
namespace Kiseki.Launcher
|
||||
namespace Kiseki.Launcher.Helpers
|
||||
{
|
||||
public static class Helpers
|
||||
public static class Base64
|
||||
{
|
||||
// https://stackoverflow.com/a/54143400
|
||||
public static bool IsBase64String(string base64)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
using System.Text.Json;
|
||||
|
||||
namespace Kiseki.Launcher.Helpers
|
||||
{
|
||||
public static class Http
|
||||
{
|
||||
public static async Task<T?> GetJson<T>(string url)
|
||||
{
|
||||
string json = await Controller.HttpClient.GetStringAsync(url);
|
||||
|
||||
try
|
||||
{
|
||||
return JsonSerializer.Deserialize<T>(json);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
namespace Kiseki.Launcher
|
||||
{
|
||||
public interface ILauncher
|
||||
{
|
||||
void Register();
|
||||
void Unregister();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,12 +1,6 @@
|
|||
namespace Kiseki.Launcher
|
||||
{
|
||||
interface ILauncher
|
||||
{
|
||||
void Register();
|
||||
void Unregister();
|
||||
}
|
||||
|
||||
interface IProtocol
|
||||
public interface IProtocol
|
||||
{
|
||||
void Register(string key, string name, string handler);
|
||||
void Unregister(string key);
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
namespace Kiseki.Launcher.Models
|
||||
{
|
||||
public class HealthCheck
|
||||
{
|
||||
public string Response { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue