Launching server.
This commit is contained in:
32
Wino.Shared.WinRT/Services/ServerConnectionManagerBase.cs
Normal file
32
Wino.Shared.WinRT/Services/ServerConnectionManagerBase.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Wino.Domain.Enums;
|
||||
using Wino.Domain.Interfaces;
|
||||
|
||||
namespace Wino.Shared.WinRT.Services
|
||||
{
|
||||
public abstract class ServerConnectionManagerBase : IWinoServerConnectionManager
|
||||
{
|
||||
public event EventHandler<WinoServerConnectionStatus> StatusChanged;
|
||||
|
||||
private WinoServerConnectionStatus status;
|
||||
|
||||
public WinoServerConnectionStatus Status
|
||||
{
|
||||
get { return status; }
|
||||
private set
|
||||
{
|
||||
status = value;
|
||||
StatusChanged?.Invoke(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Task<bool> ConnectAsync() => throw new NotImplementedException();
|
||||
|
||||
public Task<bool> DisconnectAsync() => throw new NotImplementedException();
|
||||
|
||||
public void DisposeConnection() => throw new NotImplementedException();
|
||||
|
||||
public void QueueRequest(IRequestBase request, Guid accountId) => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
41
Wino.Shared.WinRT/Services/WinoIPCServerConnectionManager.cs
Normal file
41
Wino.Shared.WinRT/Services/WinoIPCServerConnectionManager.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.ApplicationModel;
|
||||
using Wino.Domain.Interfaces;
|
||||
|
||||
namespace Wino.Shared.WinRT.Services
|
||||
{
|
||||
public class WinoIPCServerConnectionManager : ServerConnectionManagerBase, IWinoServerConnectionManager
|
||||
{
|
||||
public override Task<bool> ConnectAsync()
|
||||
{
|
||||
string directory = Path.Combine(Package.Current.InstalledLocation.Path, "Wino.Server", "Wino.Server.exe");
|
||||
|
||||
Process P = new();
|
||||
P.StartInfo.UseShellExecute = true;
|
||||
P.StartInfo.Verb = "runas";
|
||||
P.StartInfo.FileName = directory;
|
||||
|
||||
// TODO: Pass server start arguments with additional options.
|
||||
P.StartInfo.Arguments = "";
|
||||
|
||||
return Task.FromResult(P.Start());
|
||||
}
|
||||
|
||||
//public Task<bool> DisconnectAsync()
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
|
||||
//public void DisposeConnection()
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
|
||||
//public void QueueRequest(IRequestBase request, Guid accountId)
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Windows.ApplicationModel.AppService;
|
||||
using Wino.Domain.Interfaces;
|
||||
using Wino.Shared.WinRT.Services;
|
||||
|
||||
@@ -9,10 +8,15 @@ namespace Wino.Shared.WinRT
|
||||
{
|
||||
public static void RegisterCoreUWPServices(this IServiceCollection services)
|
||||
{
|
||||
var serverConnectionManager = new WinoServerConnectionManager();
|
||||
// AppServiceConnection works only for UWP.
|
||||
|
||||
// var serverConnectionManager = new WinoServerConnectionManager();
|
||||
//services.AddSingleton<IWinoServerConnectionManager>(serverConnectionManager);
|
||||
//services.AddSingleton<IWinoServerConnectionManager<AppServiceConnection>>(serverConnectionManager);
|
||||
|
||||
// Use new IPC server for WinAppSDK
|
||||
var serverConnectionManager = new WinoIPCServerConnectionManager();
|
||||
services.AddSingleton<IWinoServerConnectionManager>(serverConnectionManager);
|
||||
services.AddSingleton<IWinoServerConnectionManager<AppServiceConnection>>(serverConnectionManager);
|
||||
|
||||
services.AddSingleton<IUnderlyingThemeService, UnderlyingThemeService>();
|
||||
services.AddSingleton<INativeAppService, NativeAppService>();
|
||||
|
||||
Reference in New Issue
Block a user