M Samples/FileClient/FileClient.csproj => Samples/FileClient/FileClient.csproj +0 -4
@@ 9,10 9,6 @@
</PropertyGroup>
<ItemGroup>
- <Folder Include="Handlers" />
- </ItemGroup>
-
- <ItemGroup>
<ProjectReference Include="..\..\Core\NosSmooth.Core\NosSmooth.Core.csproj" />
<ProjectReference Include="..\..\Core\NosSmooth.Game\NosSmooth.Game.csproj" />
<ProjectReference Include="..\..\Data\NosSmooth.Data.Abstractions\NosSmooth.Data.Abstractions.csproj" />
M Samples/FileClient/Program.cs => Samples/FileClient/Program.cs +2 -0
@@ 4,6 4,7 @@
// Copyright (c) František Boháček. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+using FileClient.Responders;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
@@ 48,6 49,7 @@ public static class Program
coll.AddNostaleCore()
.AddNostaleGame()
.AddNostaleDataFiles()
+ .AddPacketResponder<PacketNotFoundResponder>()
.Configure<LanguageServiceOptions>(o => o.Language = Language.Cz)
.Configure<NostaleDataOptions>(o => o.SupportedLanguages = new[]
{
A Samples/FileClient/Responders/PacketNotFoundResponder.cs => Samples/FileClient/Responders/PacketNotFoundResponder.cs +43 -0
@@ 0,0 1,43 @@
+//
+// PacketNotFoundResponder.cs
+//
+// Copyright (c) František Boháček. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+
+using Microsoft.Extensions.Logging;
+using NosSmooth.Core.Packets;
+using NosSmooth.Packets;
+using Remora.Results;
+
+namespace FileClient.Responders;
+
+/// <summary>
+/// Responds to packets that were not found.
+/// </summary>
+public class PacketNotFoundResponder : IPacketResponder<UnresolvedPacket>, IPacketResponder<ParsingFailedPacket>
+{
+ private readonly ILogger<PacketNotFoundResponder> _logger;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PacketNotFoundResponder"/> class.
+ /// </summary>
+ /// <param name="logger">The logger.</param>
+ public PacketNotFoundResponder(ILogger<PacketNotFoundResponder> logger)
+ {
+ _logger = logger;
+ }
+
+ /// <inheritdoc />
+ public Task<Result> Respond(PacketEventArgs<UnresolvedPacket> packetArgs, CancellationToken ct = default)
+ {
+ _logger.LogWarning($"Could not find packet {packetArgs.PacketString}");
+ return Task.FromResult(Result.FromSuccess());
+ }
+
+ /// <inheritdoc />
+ public Task<Result> Respond(PacketEventArgs<ParsingFailedPacket> packetArgs, CancellationToken ct = default)
+ {
+ _logger.LogWarning($"Could not parse packet {packetArgs.PacketString}");
+ return Task.FromResult(Result.FromSuccess());
+ }
+}<
\ No newline at end of file