M Core/NosSmooth.Core/Commands/Control/ControlCommandPacketResponders.cs => Core/NosSmooth.Core/Commands/Control/ControlCommandPacketResponders.cs +1 -1
@@ 17,7 17,7 @@ namespace NosSmooth.Core.Commands.Control;
/// <summary>
/// Packet responder for cancellation of <see cref="TakeControlCommand"/>.
/// </summary>
-public class ControlCommandPacketResponders : IPacketResponder<CMapPacket>
+internal class ControlCommandPacketResponders : IPacketResponder<CMapPacket>
{
private readonly ControlCommands _controlCommands;
M Core/NosSmooth.Core/Commands/Control/TakeControlCommandHandler.cs => Core/NosSmooth.Core/Commands/Control/TakeControlCommandHandler.cs +1 -1
@@ 14,7 14,7 @@ namespace NosSmooth.Core.Commands.Control;
/// <summary>
/// Handles <see cref="TakeControlCommand"/>.
/// </summary>
-public class TakeControlCommandHandler : ICommandHandler<TakeControlCommand>
+internal class TakeControlCommandHandler : ICommandHandler<TakeControlCommand>
{
private readonly ControlCommands _commands;
M Core/NosSmooth.Core/Commands/Walking/WalkCommandHandler.cs => Core/NosSmooth.Core/Commands/Walking/WalkCommandHandler.cs +1 -1
@@ 18,7 18,7 @@ namespace NosSmooth.Core.Commands.Walking;
/// <summary>
/// Handles <see cref="WalkCommand"/>.
/// </summary>
-public class WalkCommandHandler : ICommandHandler<WalkCommand>
+internal class WalkCommandHandler : ICommandHandler<WalkCommand>
{
private readonly INostaleClient _nostaleClient;
M Core/NosSmooth.Core/Extensions/ServiceCollectionExtensions.cs => Core/NosSmooth.Core/Extensions/ServiceCollectionExtensions.cs +1 -1
@@ 34,7 34,7 @@ public static class ServiceCollectionExtensions
)
{
serviceCollection
- .TryAddSingleton<IPacketHandler, PacketHandler>();
+ .TryAddSingleton<PacketHandler>();
serviceCollection.AddPacketSerialization();
serviceCollection.AddSingleton<CommandProcessor>();
D Core/NosSmooth.Core/Packets/IPacketHandler.cs => Core/NosSmooth.Core/Packets/IPacketHandler.cs +0 -39
@@ 1,39 0,0 @@
-//
-// IPacketHandler.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 System.Threading;
-using System.Threading.Tasks;
-using NosSmooth.Core.Client;
-using NosSmooth.Packets;
-using Remora.Results;
-
-namespace NosSmooth.Core.Packets;
-
-/// <summary>
-/// Calls registered responders for the packet that should be handled.
-/// </summary>
-public interface IPacketHandler
-{
- /// <summary>
- /// Calls a responder for the given packet.
- /// </summary>
- /// <param name="client">The current NosTale client.</param>
- /// <param name="packet">The packet.</param>
- /// <param name="packetString">The string of the packet.</param>
- /// <param name="ct">The cancellation token for cancelling the operation.</param>
- /// <returns>A result that may or may not have succeeded.</returns>
- public Task<Result> HandleReceivedPacketAsync(INostaleClient client, IPacket packet, string packetString, CancellationToken ct = default);
-
- /// <summary>
- /// Calls a responder for the given packet.
- /// </summary>
- /// <param name="client">The current NosTale client.</param>
- /// <param name="packet">The packet.</param>
- /// <param name="packetString">The string of the packet.</param>
- /// <param name="ct">The cancellation token for cancelling the operation.</param>
- /// <returns>A result that may or may not have succeeded.</returns>
- public Task<Result> HandleSentPacketAsync(INostaleClient client, IPacket packet, string packetString, CancellationToken ct = default);
-}
M Core/NosSmooth.Core/Packets/PacketHandler.cs => Core/NosSmooth.Core/Packets/PacketHandler.cs +46 -9
@@ 18,8 18,10 @@ using Remora.Results;
namespace NosSmooth.Core.Packets;
-/// <inheritdoc />
-public class PacketHandler : IPacketHandler
+/// <summary>
+/// Calls registered responders for the packet that should be handled.
+/// </summary>
+public class PacketHandler
{
private readonly IServiceProvider _provider;
@@ 32,25 34,53 @@ public class PacketHandler : IPacketHandler
_provider = provider;
}
- /// <inheritdoc />
+ /// <summary>
+ /// Calls a responder for the given packet.
+ /// </summary>
+ /// <param name="client">The current NosTale client.</param>
+ /// <param name="packet">The packet.</param>
+ /// <param name="packetString">The string of the packet.</param>
+ /// <param name="ct">The cancellation token for cancelling the operation.</param>
+ /// <returns>A result that may or may not have succeeded.</returns>
public Task<Result> HandleReceivedPacketAsync
(
INostaleClient client,
IPacket packet,
string packetString,
- CancellationToken ct
+ CancellationToken ct = default
)
- => HandlePacketAsync(client, PacketSource.Server, packet, packetString, ct);
+ => HandlePacketAsync
+ (
+ client,
+ PacketSource.Server,
+ packet,
+ packetString,
+ ct
+ );
- /// <inheritdoc />
+ /// <summary>
+ /// Calls a responder for the given packet.
+ /// </summary>
+ /// <param name="client">The current NosTale client.</param>
+ /// <param name="packet">The packet.</param>
+ /// <param name="packetString">The string of the packet.</param>
+ /// <param name="ct">The cancellation token for cancelling the operation.</param>
+ /// <returns>A result that may or may not have succeeded.</returns>
public Task<Result> HandleSentPacketAsync
(
INostaleClient client,
IPacket packet,
string packetString,
- CancellationToken ct
+ CancellationToken ct = default
)
- => HandlePacketAsync(client, PacketSource.Client, packet, packetString, ct);
+ => HandlePacketAsync
+ (
+ client,
+ PacketSource.Client,
+ packet,
+ packetString,
+ ct
+ );
private Task<Result> HandlePacketAsync
(
@@ 131,7 161,14 @@ public class PacketHandler : IPacketHandler
}
}
- var postExecutionResult = await ExecuteAfterExecutionAsync(scope.ServiceProvider, client, packetEventArgs, results, ct);
+ var postExecutionResult = await ExecuteAfterExecutionAsync
+ (
+ scope.ServiceProvider,
+ client,
+ packetEventArgs,
+ results,
+ ct
+ );
if (!postExecutionResult.IsSuccess)
{
errors.Add(postExecutionResult);
M Core/NosSmooth.Core/Stateful/StatefulInjector.cs => Core/NosSmooth.Core/Stateful/StatefulInjector.cs +1 -1
@@ 12,7 12,7 @@ namespace NosSmooth.Core.Stateful;
/// <summary>
/// The scoped injector of stateful entities.
/// </summary>
-public class StatefulInjector
+internal class StatefulInjector
{
private readonly StatefulRepository _repository;
M Core/NosSmooth.Core/Stateful/StatefulPreExecutionEvent.cs => Core/NosSmooth.Core/Stateful/StatefulPreExecutionEvent.cs +1 -1
@@ 19,7 19,7 @@ namespace NosSmooth.Core.Stateful;
/// <summary>
/// Event that injects stateful entities into the scope.
/// </summary>
-public class StatefulPreExecutionEvent : IPreExecutionEvent, IPreCommandExecutionEvent
+internal class StatefulPreExecutionEvent : IPreExecutionEvent, IPreCommandExecutionEvent
{
private readonly StatefulInjector _injector;
M Core/NosSmooth.Core/Stateful/StatefulRepository.cs => Core/NosSmooth.Core/Stateful/StatefulRepository.cs +1 -1
@@ 15,7 15,7 @@ namespace NosSmooth.Core.Stateful;
/// <summary>
/// Repository holding all the stateful entities for various NosTale clients.
/// </summary>
-public class StatefulRepository
+internal class StatefulRepository
{
private readonly Dictionary<INostaleClient, Dictionary<Type, object>> _statefulEntities;
D Tests/NosSmooth.Core.Tests/Packets/InPacketSerializerTest.cs => Tests/NosSmooth.Core.Tests/Packets/InPacketSerializerTest.cs +0 -1
@@ 1,1 0,0 @@
->
\ No newline at end of file