Launching server.
This commit is contained in:
@@ -14,9 +14,6 @@ using Microsoft.AppCenter.Crashes;
|
||||
using MoreLinq;
|
||||
using Serilog;
|
||||
using Wino.Domain;
|
||||
using Wino.Domain.Models.MailItem;
|
||||
using Wino.Domain.Models.Synchronization;
|
||||
using Wino.Domain;
|
||||
using Wino.Domain.Entities;
|
||||
using Wino.Domain.Enums;
|
||||
using Wino.Domain.Interfaces;
|
||||
@@ -24,6 +21,7 @@ using Wino.Domain.Models.Folders;
|
||||
using Wino.Domain.Models.MailItem;
|
||||
using Wino.Domain.Models.Menus;
|
||||
using Wino.Domain.Models.Reader;
|
||||
using Wino.Domain.Models.Synchronization;
|
||||
using Wino.Mail.ViewModels.Collections;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
using Wino.Mail.ViewModels.Messages;
|
||||
|
||||
@@ -60,6 +60,11 @@ namespace Wino
|
||||
|
||||
m_ShellFrame.Navigate(typeof(AppShell));
|
||||
m_Window.Activate();
|
||||
|
||||
// Launch server
|
||||
|
||||
var serverConnectionManager = Services.GetService<IWinoServerConnectionManager>();
|
||||
await serverConnectionManager.ConnectAsync();
|
||||
}
|
||||
|
||||
private void ConfigureWindow()
|
||||
|
||||
@@ -23,10 +23,6 @@ using Wino.Domain.Models.Folders;
|
||||
using Wino.Domain.Interfaces;
|
||||
using Wino.Domain.Models.MailItem;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if NET8_0
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
|
||||
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