1
0
mirror of https://github.com/oliverbooth/TcpDotNet synced 2024-11-09 23:05:41 +00:00

refactor!: rename BaseClientNode to ClientNode

This commit is contained in:
Oliver Booth 2024-02-12 17:32:29 +00:00
parent e7dfe97c6d
commit 259fdddd6e
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5
11 changed files with 16 additions and 16 deletions

View File

@ -4,7 +4,7 @@ namespace TcpDotNet.ClientIntegrationTest.PacketHandlers;
internal sealed class GoodbyePacketHandler : PacketHandler<GoodbyePacket>
{
public override Task HandleAsync(BaseClientNode recipient, GoodbyePacket packet, CancellationToken cancellationToken = default)
public override Task HandleAsync(ClientNode recipient, GoodbyePacket packet, CancellationToken cancellationToken = default)
{
Console.WriteLine($"Server sent {packet.Message}");
return Task.CompletedTask;

View File

@ -4,7 +4,7 @@ namespace TcpDotNet.ListenerIntegrationTest.PacketHandlers;
internal sealed class HelloPacketHandler : PacketHandler<HelloPacket>
{
public override Task HandleAsync(BaseClientNode recipient, HelloPacket packet, CancellationToken cancellationToken = default)
public override Task HandleAsync(ClientNode recipient, HelloPacket packet, CancellationToken cancellationToken = default)
{
Console.WriteLine($"Client sent {packet.Message}");
return recipient.SendPacketAsync(new GoodbyePacket {Message = "Goodbye!"}, cancellationToken);

View File

@ -16,7 +16,7 @@ await Task.Delay(-1);
internal sealed class PingPacketHandler : PacketHandler<PingPacket>
{
public override async Task HandleAsync(BaseClientNode recipient, PingPacket packet, CancellationToken cancellationToken = default)
public override async Task HandleAsync(ClientNode recipient, PingPacket packet, CancellationToken cancellationToken = default)
{
Console.WriteLine($"Client {recipient.SessionId} sent ping with payload {BitConverter.ToString(packet.Payload)}");
var pong = new PongPacket(packet.CallbackId, packet.Payload);

View File

@ -13,16 +13,16 @@ namespace TcpDotNet;
/// <summary>
/// Represents a client node.
/// </summary>
public abstract class BaseClientNode : Node
public abstract class ClientNode : Node
{
private readonly ObjectIDGenerator _callbackIdGenerator = new();
private readonly ConcurrentDictionary<int, List<TaskCompletionSource<Packet>>> _packetCompletionSources = new();
private EndPoint? _remoteEP;
/// <summary>
/// Initializes a new instance of the <see cref="BaseClientNode" /> class.
/// Initializes a new instance of the <see cref="ClientNode" /> class.
/// </summary>
protected BaseClientNode()
protected ClientNode()
{
}

View File

@ -1,7 +1,7 @@
namespace TcpDotNet;
/// <summary>
/// An enumeration of states for a <see cref="BaseClientNode" /> to be in.
/// An enumeration of states for a <see cref="ClientNode" /> to be in.
/// </summary>
public enum ClientState
{

View File

@ -12,7 +12,7 @@ public abstract class PacketHandler
/// <param name="recipient">The recipient of the packet.</param>
/// <param name="packet">The packet to handle.</param>
/// <param name="cancellationToken">A cancellation token that can be used to cancel the asynchronous operation.</param>
public abstract Task HandleAsync(BaseClientNode recipient, Packet packet, CancellationToken cancellationToken = default);
public abstract Task HandleAsync(ClientNode recipient, Packet packet, CancellationToken cancellationToken = default);
}
/// <summary>
@ -27,7 +27,7 @@ public abstract class PacketHandler<T> : PacketHandler
public static readonly PacketHandler<T> Empty = new NullPacketHandler<T>();
/// <inheritdoc />
public override Task HandleAsync(BaseClientNode recipient, Packet packet, CancellationToken cancellationToken = default)
public override Task HandleAsync(ClientNode recipient, Packet packet, CancellationToken cancellationToken = default)
{
if (packet is T actual) return HandleAsync(recipient, actual, cancellationToken);
return Task.CompletedTask;
@ -39,7 +39,7 @@ public abstract class PacketHandler<T> : PacketHandler
/// <param name="recipient">The recipient of the packet.</param>
/// <param name="packet">The packet to handle.</param>
/// <param name="cancellationToken">A cancellation token that can be used to cancel the asynchronous operation.</param>
public abstract Task HandleAsync(BaseClientNode recipient, T packet, CancellationToken cancellationToken = default);
public abstract Task HandleAsync(ClientNode recipient, T packet, CancellationToken cancellationToken = default);
}
/// <summary>
@ -50,7 +50,7 @@ internal sealed class NullPacketHandler<T> : PacketHandler<T>
where T : Packet
{
/// <inheritdoc />
public override Task HandleAsync(BaseClientNode recipient, T packet, CancellationToken cancellationToken = default)
public override Task HandleAsync(ClientNode recipient, T packet, CancellationToken cancellationToken = default)
{
return Task.CompletedTask;
}

View File

@ -6,7 +6,7 @@ internal sealed class DisconnectPacketHandler : PacketHandler<DisconnectPacket>
{
/// <inheritdoc />
public override Task HandleAsync(
BaseClientNode recipient,
ClientNode recipient,
DisconnectPacket packet,
CancellationToken cancellationToken = default
)

View File

@ -11,7 +11,7 @@ internal sealed class EncryptionResponsePacketHandler : PacketHandler<Encryption
{
/// <inheritdoc />
public override async Task HandleAsync(
BaseClientNode recipient,
ClientNode recipient,
EncryptionResponsePacket packet,
CancellationToken cancellationToken = default
)

View File

@ -10,7 +10,7 @@ internal sealed class HandshakeRequestPacketHandler : PacketHandler<HandshakeReq
{
/// <inheritdoc />
public override async Task HandleAsync(
BaseClientNode recipient,
ClientNode recipient,
HandshakeRequestPacket packet,
CancellationToken cancellationToken = default
)

View File

@ -14,7 +14,7 @@ namespace TcpDotNet;
/// <summary>
/// Represents a client on the TcpDotNet protocol.
/// </summary>
public sealed class ProtocolClient : BaseClientNode
public sealed class ProtocolClient : ClientNode
{
/// <summary>
/// Initializes a new instance of the <see cref="ProtocolClient" /> class.

View File

@ -8,7 +8,7 @@ public sealed partial class ProtocolListener
/// <summary>
/// Represents a client that is connected to a <see cref="ProtocolListener" />.
/// </summary>
public sealed class Client : BaseClientNode
public sealed class Client : ClientNode
{
internal Client(ProtocolListener listener, Socket socket)
{