| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 | 
							- 
 
- namespace EEMSService;
 
- public class EEMSBaseServer : IDisposable
 
- {
 
-     public WebApplication? WebApplication { get; private set; }
 
-     public bool Initialize(long messageSize = 26144)//26144:256kb
 
-     {
 
-         if (WebApplication is not null)
 
-             return false;
 
-         WebApplicationBuilder builder = WebApplication.CreateBuilder();
 
-         builder.Services.AddSignalR(
 
-             options =>
 
-             {
 
-                 options.EnableDetailedErrors = true; 
 
-                 options.MaximumReceiveMessageSize = messageSize;
 
-             });
 
-         builder.Services.AddHostedService<HostLifeTime>();
 
-         builder.Services.AddSingleton<DeviceManager>();
 
-         builder.Services.AddSingleton<ClientManager>();
 
-         builder.Services.AddSingleton<UISender>();
 
-         WebApplication = builder.Build();
 
-         WebApplication.MapHub<UIHub>("/UIHub");
 
-         WebApplication.MapHub<ClientsHub>("/ClientHub");
 
-         return true;
 
-     }
 
-     public async Task<bool> StartService(string ip, ushort port)
 
-     {
 
-         if (WebApplication is null)
 
-             return false;
 
-         if (string.IsNullOrEmpty(ip) || port < 1000)
 
-             return false;
 
-         try
 
-         {
 
-             await WebApplication.RunAsync($"http://{ip}:{port}");
 
-         }
 
-         catch
 
-         {
 
-             return false;
 
-         }
 
-         return true;
 
-     }
 
-     #region Dispose
 
-     private bool disposedValue;
 
-     protected virtual void Dispose(bool disposing)
 
-     {
 
-         if (!disposedValue)
 
-         {
 
-             if (disposing)
 
-             {
 
-                 // TODO: dispose managed state (managed objects)
 
-                 this.WebApplication?.DisposeAsync().AsTask().Wait();
 
-                 this.WebApplication = null;
 
-             }
 
-             // TODO: free unmanaged resources (unmanaged objects) and override finalizer
 
-             // TODO: set large fields to null
 
-             disposedValue = true;
 
-         }
 
-     }
 
-     // // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
 
-     // ~EEMS_Server()
 
-     // {
 
-     //     // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
 
-     //     Dispose(disposing: false);
 
-     // }
 
-     public void Dispose()
 
-     {
 
-         // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
 
-         Dispose(disposing: true);
 
-         GC.SuppressFinalize(this);
 
-     }
 
-     #endregion
 
- }
 
 
  |