From 025319a302fb35e1fa881897400a050249a7a65a Mon Sep 17 00:00:00 2001 From: Rutherther Date: Wed, 4 Jan 2023 22:36:47 +0100 Subject: [PATCH] feat(samples): update file client QoL --- Samples/FileClient/App.cs | 3 ++- Samples/FileClient/Client.cs | 2 +- Samples/FileClient/Program.cs | 2 +- Samples/FileClient/Responders/PacketNotFoundResponder.cs | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Samples/FileClient/App.cs b/Samples/FileClient/App.cs index d4a087a..46b4378 100644 --- a/Samples/FileClient/App.cs +++ b/Samples/FileClient/App.cs @@ -71,7 +71,8 @@ public class App : BackgroundService if (!runResult.IsSuccess) { _logger.LogResultError(runResult); - await _lifetime.StopAsync(default); } + + await _lifetime.StopAsync(default); } } \ No newline at end of file diff --git a/Samples/FileClient/Client.cs b/Samples/FileClient/Client.cs index 95cd724..ad94e8c 100644 --- a/Samples/FileClient/Client.cs +++ b/Samples/FileClient/Client.cs @@ -62,7 +62,7 @@ public class Client : BaseNostaleClient { stopRequested.ThrowIfCancellationRequested(); var line = await reader.ReadLineAsync(); - if (line is null) + if (string.IsNullOrEmpty(line)) { continue; } diff --git a/Samples/FileClient/Program.cs b/Samples/FileClient/Program.cs index bf35255..a13ad23 100644 --- a/Samples/FileClient/Program.cs +++ b/Samples/FileClient/Program.cs @@ -36,7 +36,7 @@ public static class Program public static async Task Main(string[] args) { await using FileStream stream = File.OpenRead(string.Join(' ', args)); - await CreateHost(stream).StartAsync(); + await CreateHost(stream).RunAsync(); } private static IHost CreateHost(Stream fileStream) diff --git a/Samples/FileClient/Responders/PacketNotFoundResponder.cs b/Samples/FileClient/Responders/PacketNotFoundResponder.cs index 94caf5c..07e29f4 100644 --- a/Samples/FileClient/Responders/PacketNotFoundResponder.cs +++ b/Samples/FileClient/Responders/PacketNotFoundResponder.cs @@ -5,6 +5,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.Extensions.Logging; +using NosSmooth.Core.Extensions; using NosSmooth.Core.Packets; using NosSmooth.Packets; using Remora.Results; @@ -38,6 +39,7 @@ public class PacketNotFoundResponder : IPacketResponder, IPack public Task Respond(PacketEventArgs packetArgs, CancellationToken ct = default) { _logger.LogWarning($"Could not parse packet {packetArgs.PacketString}"); + _logger.LogResultError(packetArgs.Packet.SerializerResult); return Task.FromResult(Result.FromSuccess()); } } \ No newline at end of file -- 2.49.0