Timothy Schenk
a547d6ebbf
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 2s
Build, Package and Push Images / build (push) Successful in 29s
Build, Package and Push Images / sbom-scan (push) Successful in 38s
Build, Package and Push Images / sonarqube (push) Successful in 1m21s
Build, Package and Push Images / container-build (push) Successful in 1m21s
Build, Package and Push Images / container-sbom-scan (push) Successful in 33s
30 lines
760 B
C#
30 lines
760 B
C#
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
|
|
|
using JetBrains.Annotations;
|
|
using NetCoreServer;
|
|
using Wonderking.Packets;
|
|
|
|
namespace Server.PacketHandlers;
|
|
|
|
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
|
|
public interface IPacketHandler<in T> : IPacketHandler where T : IPacket
|
|
{
|
|
[UsedImplicitly]
|
|
public Task HandleAsync(T packet, TcpSession session);
|
|
|
|
async Task<bool> IPacketHandler.TryHandleAsync(IPacket packet, TcpSession session)
|
|
{
|
|
if (packet is T tPacket)
|
|
{
|
|
await HandleAsync(tPacket, session);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public interface IPacketHandler
|
|
{
|
|
Task<bool> TryHandleAsync(IPacket packet, TcpSession session);
|
|
}
|