[ci skip] style: run code cleanup
This commit is contained in:
parent
32fecb5ace
commit
0c5c2087b9
|
@ -239,7 +239,8 @@ public abstract class ClientNode : Node
|
|||
requestPacket.CallbackId = _callbackIdGenerator.GetId(packetToSend, out _);
|
||||
|
||||
var completionSource = new TaskCompletionSource<Packet>();
|
||||
if (!_packetCompletionSources.TryGetValue(attribute.Id, out List<TaskCompletionSource<Packet>>? completionSources))
|
||||
if (!_packetCompletionSources.TryGetValue(attribute.Id,
|
||||
out List<TaskCompletionSource<Packet>>? completionSources))
|
||||
{
|
||||
completionSources = new List<TaskCompletionSource<Packet>>();
|
||||
_packetCompletionSources.TryAdd(attribute.Id, completionSources);
|
||||
|
@ -292,7 +293,8 @@ public abstract class ClientNode : Node
|
|||
if (attribute is null)
|
||||
throw new ArgumentException($"The packet type {typeof(TPacket).Name} is not a valid packet.");
|
||||
|
||||
if (!_packetCompletionSources.TryGetValue(attribute.Id, out List<TaskCompletionSource<Packet>>? completionSources))
|
||||
if (!_packetCompletionSources.TryGetValue(attribute.Id,
|
||||
out List<TaskCompletionSource<Packet>>? completionSources))
|
||||
{
|
||||
completionSources = new List<TaskCompletionSource<Packet>>();
|
||||
_packetCompletionSources.TryAdd(attribute.Id, completionSources);
|
||||
|
|
|
@ -38,7 +38,8 @@ public abstract class Node : IDisposable
|
|||
/// <value>The registered packets.</value>
|
||||
public IReadOnlyDictionary<Type, IReadOnlyCollection<PacketHandler>> RegisteredPacketHandlers =>
|
||||
new ReadOnlyDictionary<Type, IReadOnlyCollection<PacketHandler>>(
|
||||
_registeredPacketHandlers.ToDictionary(p => p.Key, p => (IReadOnlyCollection<PacketHandler>) p.Value.AsReadOnly()));
|
||||
_registeredPacketHandlers.ToDictionary(p => p.Key,
|
||||
p => (IReadOnlyCollection<PacketHandler>)p.Value.AsReadOnly()));
|
||||
|
||||
/// <summary>
|
||||
/// Closes the base socket connection and releases all associated resources.
|
||||
|
@ -124,7 +125,8 @@ public abstract class Node : IDisposable
|
|||
var attribute = packetType.GetCustomAttribute<PacketAttribute>();
|
||||
if (attribute is null) throw new ArgumentException($"{packetType.Name} is not a valid packet.");
|
||||
if (_registeredPackets.TryGetValue(attribute.Id, out Type? registeredPacket))
|
||||
throw new ArgumentException($"The packet type {attribute.Id:X8} is already registered to {registeredPacket.Name}.");
|
||||
throw new ArgumentException(
|
||||
$"The packet type {attribute.Id:X8} is already registered to {registeredPacket.Name}.");
|
||||
|
||||
_registeredPackets.TryAdd(attribute.Id, packetType);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ internal sealed class HandshakeRequestPacketHandler : PacketHandler<HandshakeReq
|
|||
|
||||
if (packet.ProtocolVersion != Node.ProtocolVersion)
|
||||
{
|
||||
response = new HandshakeResponsePacket(packet.ProtocolVersion, HandshakeResponse.UnsupportedProtocolVersion);
|
||||
response = new HandshakeResponsePacket(packet.ProtocolVersion,
|
||||
HandshakeResponse.UnsupportedProtocolVersion);
|
||||
await client.SendPacketAsync(response, cancellationToken);
|
||||
client.Close();
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Net;
|
||||
using System.Net;
|
||||
using System.Numerics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
|
|
@ -35,7 +35,8 @@ public sealed partial class ProtocolListener
|
|||
foreach (Type packetType in ParentListener.RegisteredPackets.Values)
|
||||
RegisterPacket(packetType);
|
||||
|
||||
foreach ((Type packetType, IReadOnlyCollection<PacketHandler>? handlers) in ParentListener.RegisteredPacketHandlers)
|
||||
foreach ((Type packetType, IReadOnlyCollection<PacketHandler>? handlers) in ParentListener
|
||||
.RegisteredPacketHandlers)
|
||||
foreach (PacketHandler handler in handlers)
|
||||
RegisterPacketHandler(packetType, handler);
|
||||
|
||||
|
|
Loading…
Reference in New Issue