diff --git a/src/libs/H.Pipes/PipeServer.cs b/src/libs/H.Pipes/PipeServer.cs index 806d0ab..978a422 100644 --- a/src/libs/H.Pipes/PipeServer.cs +++ b/src/libs/H.Pipes/PipeServer.cs @@ -16,14 +16,10 @@ public sealed class PipeServer : IPipeServer { #region Properties - /// - /// Name of pipe - /// + /// public string PipeName { get; } - /// - /// CreatePipeStreamFunc - /// + /// public Func? CreatePipeStreamFunc { get; set; } /// @@ -31,14 +27,10 @@ public sealed class PipeServer : IPipeServer /// public Func? CreatePipeStreamForConnectionFunc { get; set; } - /// - /// PipeStreamInitializeAction - /// + /// public Action? PipeStreamInitializeAction { get; set; } - /// - /// Used formatter - /// + /// public IFormatter Formatter { get; set; } /// @@ -58,11 +50,8 @@ public sealed class PipeServer : IPipeServer .Where(connection => connection.IsConnected) .ToList(); - /// - /// IsStarted - /// - public bool IsStarted => ListenWorker != null && !ListenWorker.Task.IsCompleted && !ListenWorker.Task.IsCanceled && !ListenWorker.Task.IsFaulted; - + /// + public bool IsStarted => ListenWorker is { Task: { IsCompleted: false, IsCanceled: false, IsFaulted: false } }; private TaskWorker? ListenWorker { get; set; } @@ -72,24 +61,16 @@ public sealed class PipeServer : IPipeServer #region Events - /// - /// Invoked whenever a client connects to the server. - /// + /// public event EventHandler>? ClientConnected; - /// - /// Invoked whenever a client disconnects from the server. - /// + /// public event EventHandler>? ClientDisconnected; - /// - /// Invoked whenever a client sends a message to the server. - /// + /// public event EventHandler>? MessageReceived; - /// - /// Invoked whenever an exception is thrown during a read or write operation. - /// + /// public event EventHandler? ExceptionOccurred; private void OnClientConnected(ConnectionEventArgs args) @@ -131,12 +112,7 @@ public PipeServer(string pipeName, IFormatter? formatter = default) #region Public methods - /// - /// Begins listening for client connections in a separate background thread. - /// This method waits when pipe will be created(or throws exception). - /// - /// - /// + /// public async Task StartAsync(CancellationToken cancellationToken = default) { if (IsStarted) @@ -300,9 +276,7 @@ public async Task WriteAsync(T value, string pipeName, CancellationToken cancell await WriteAsync(value, connection => connection.PipeName == pipeName, cancellationToken).ConfigureAwait(false); } - /// - /// Closes all open client connections and stops listening for new ones. - /// + /// public async Task StopAsync(CancellationToken _ = default) { if (ListenWorker != null) @@ -325,9 +299,7 @@ public async Task StopAsync(CancellationToken _ = default) #region IDisposable - /// - /// Dispose internal resources - /// + /// public async ValueTask DisposeAsync() { if (_isDisposed)