Archived
1
0
Fork 0
forked from Moux23333/FreeSR
This repository has been archived on 2024-03-30. You can view files and clone it, but cannot push or open issues or pull requests.
FreeSR/FreeSR.Gateserver/Network/Handlers/Decoder/PacketDecoder.cs
2024-01-27 21:06:07 +08:00

29 lines
889 B
C#

namespace FreeSR.Gateserver.Network.Handlers.Decoder
{
using DotNetty.Buffers;
using DotNetty.Codecs;
using DotNetty.Transport.Channels;
using FreeSR.Gateserver.Network.Packet;
using NLog;
internal class PacketDecoder : MessageToMessageDecoder<IByteBuffer>
{
private static readonly Logger s_log = LogManager.GetCurrentClassLogger();
protected override void Decode(IChannelHandlerContext context, IByteBuffer message, List<object> output)
{
var netPacket = new NetPacket();
DeserializationResult result;
if ((result = netPacket.Deserialize(message)) != DeserializationResult.SUCC)
{
context.CloseAsync();
s_log.Info("Closing connection, reason: " + result);
return;
}
output.Add(netPacket);
}
}
}