using EEMSClientCore; using ServiceBase; namespace EEMSUIClient.Services { public class ClientService : IClientService, IClientProvider { private readonly IClientCaller _clientCaller; private readonly ClientCaller _hubBase; private bool disposedValue; public ClientService() { _clientCaller = new ClientCaller(); _hubBase = new HubBase(); } public event EventHandler<(Guid guid, FileType fileType)>? RequestFileReceived; public bool Initialize(string ip, int port, string hub) { if (string.IsNullOrWhiteSpace(ip) || port < 0 || string.IsNullOrWhiteSpace(hub)) { //log return false; } if (!_hubBase.Initialize(this)) { //log return false; } if (!_hubBase.Open(ip, port, hub)) { //log return false; } return true; } public Guid RegisterDevice(Models.DeviceInfo deviceInfo) { return _clientCaller.RegisterDevice(deviceInfo.Convert()).Result; } public Task RequestFile(Guid guid, FileType fileType) { //log RequestFileReceived?.Invoke(null, (guid, fileType)); return Task.FromResult(true); } protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: dispose managed state (managed objects) _hubBase?.Dispose(); } // 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 // ~ClientService() // { // // 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); } } }