2023-11-21 21:37:50 +01:00
|
|
|
// Copyright (c) 2023 Timothy Schenk. Subject to the GNU AGPL Version 3 License.
|
2023-11-20 19:58:30 +01:00
|
|
|
|
2023-11-19 17:07:28 +01:00
|
|
|
using JetBrains.Annotations;
|
|
|
|
using NetCoreServer;
|
2023-10-27 19:47:17 +02:00
|
|
|
using Wonderking.Packets;
|
|
|
|
|
2023-10-12 09:15:34 +02:00
|
|
|
namespace Server.PacketHandlers;
|
2023-08-10 10:47:35 +02:00
|
|
|
|
2023-08-13 14:12:04 +02:00
|
|
|
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
|
2023-11-22 14:55:46 +01:00
|
|
|
public interface IPacketHandler<in T> : IPacketHandler where T : IPacket
|
2023-08-09 16:23:41 +02:00
|
|
|
{
|
2023-08-12 23:02:59 +02:00
|
|
|
[UsedImplicitly]
|
2023-08-11 01:16:51 +02:00
|
|
|
public Task HandleAsync(T packet, TcpSession session);
|
2023-11-22 14:55:46 +01:00
|
|
|
|
|
|
|
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);
|
2023-08-11 11:31:30 +02:00
|
|
|
}
|