diff --git a/src/KFlearning.Core/Services/KFserverService.cs b/src/KFlearning.Core/Remoting/KFServer.cs similarity index 72% rename from src/KFlearning.Core/Services/KFserverService.cs rename to src/KFlearning.Core/Remoting/KFServer.cs index 521247c..aa69334 100644 --- a/src/KFlearning.Core/Services/KFserverService.cs +++ b/src/KFlearning.Core/Remoting/KFServer.cs @@ -1,13 +1,14 @@ -using System; +using KFlearning.Core.Services; +using System; using System.Diagnostics; using System.Linq; using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; -namespace KFlearning.Core.Services +namespace KFlearning.Core.Remoting { - public interface IKFserverService : IDisposable + public interface IKFServer : IDisposable { bool IsRunning { get; } @@ -16,7 +17,7 @@ public interface IKFserverService : IDisposable void Stop(); } - public class KFserverService : IKFserverService + public class KFServer : IKFServer { private const int ServerPort = 21002; private const string KFserverProcessName = "kfserver"; @@ -26,7 +27,7 @@ public class KFserverService : IKFserverService public bool IsRunning => Process.GetProcessesByName(KFserverProcessName).Length > 0; - public KFserverService(IPathManager pathManager) + public KFServer(IPathManager pathManager) { _pathManager = pathManager; } @@ -50,6 +51,7 @@ public void Stop() foreach (var process in Process.GetProcessesByName(KFserverProcessName)) { process.Kill(); + process?.Dispose(); } } catch (Exception) @@ -82,28 +84,14 @@ public ServerInfo GetInfo() protected virtual void Dispose(bool disposing) { - if (!_disposedValue) - { - if (disposing) - { - // TODO: dispose managed state (managed objects) - } + if (_disposedValue) return; - Stop(); - _disposedValue = true; - } + Stop(); + _disposedValue = true; } - // // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources - // ~KFserverService() - // { - // // 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); } diff --git a/src/KFlearning.Core/Services/RemoteShutdownServer.cs b/src/KFlearning.Core/Remoting/RemoteShutdownServer.cs similarity index 86% rename from src/KFlearning.Core/Services/RemoteShutdownServer.cs rename to src/KFlearning.Core/Remoting/RemoteShutdownServer.cs index ffd8ac3..ee37d0a 100644 --- a/src/KFlearning.Core/Services/RemoteShutdownServer.cs +++ b/src/KFlearning.Core/Remoting/RemoteShutdownServer.cs @@ -1,20 +1,10 @@ -// SOLUTION : KFlearning -// PROJECT : KFlearning.Core -// FILENAME : RemoteServer.cs -// AUTHOR : Fahmi Noor Fiqri, Kodesiana.com -// WEBSITE : https://kodesiana.com -// REPO : https://github.com/Kodesiana or https://github.com/fahminlb33 -// -// This file is part of KFlearning, see LICENSE. -// See this code in repository URL above! - -using System; +using System; using System.IO; using System.Net; using System.Net.Sockets; using System.Text; -namespace KFlearning.Core.Services +namespace KFlearning.Core.Remoting { public interface IRemoteShutdownServer : IDisposable { diff --git a/src/KFlearning.Core/Services/ServerInfo.cs b/src/KFlearning.Core/Remoting/ServerInfo.cs similarity index 81% rename from src/KFlearning.Core/Services/ServerInfo.cs rename to src/KFlearning.Core/Remoting/ServerInfo.cs index e12c153..845b9fe 100644 --- a/src/KFlearning.Core/Services/ServerInfo.cs +++ b/src/KFlearning.Core/Remoting/ServerInfo.cs @@ -1,4 +1,4 @@ -namespace KFlearning.Core.Services +namespace KFlearning.Core.Remoting { public class ServerInfo { diff --git a/src/KFlearning.Core/Remoting/ShutdownRequestedEventArgs.cs b/src/KFlearning.Core/Remoting/ShutdownRequestedEventArgs.cs new file mode 100644 index 0000000..e719cf8 --- /dev/null +++ b/src/KFlearning.Core/Remoting/ShutdownRequestedEventArgs.cs @@ -0,0 +1,11 @@ +using System; +using System.Net; + +namespace KFlearning.Core.Remoting +{ + public class ShutdownRequestedEventArgs : EventArgs + { + public IPAddress Address { get; set; } + public string Clusster { get; set; } + } +} \ No newline at end of file diff --git a/src/KFlearning.Core/Services/ShutdownRequestedEventArgs.cs b/src/KFlearning.Core/Services/ShutdownRequestedEventArgs.cs deleted file mode 100644 index 9cb4b58..0000000 --- a/src/KFlearning.Core/Services/ShutdownRequestedEventArgs.cs +++ /dev/null @@ -1,21 +0,0 @@ -// SOLUTION : KFlearning -// PROJECT : KFlearning.Core -// FILENAME : RemoteEventArgs.cs -// AUTHOR : Fahmi Noor Fiqri, Kodesiana.com -// WEBSITE : https://kodesiana.com -// REPO : https://github.com/Kodesiana or https://github.com/fahminlb33 -// -// This file is part of KFlearning, see LICENSE. -// See this code in repository URL above! - -using System; -using System.Net; - -namespace KFlearning.Core.Services -{ - public class ShutdownRequestedEventArgs : EventArgs - { - public IPAddress Address { get; set; } - public string Clusster { get; set; } - } -} \ No newline at end of file