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/NetSession.cs

33 lines
756 B
C#
Raw Normal View History

2024-01-27 13:06:07 +00:00
namespace FreeSR.Gateserver.Network
{
using DotNetty.Buffers;
using DotNetty.Transport.Channels;
using FreeSR.Gateserver.Network.Packet;
using FreeSR.Proto;
internal class NetSession
{
private IChannel _channel;
public NetSession(IChannel channel)
{
_channel = channel;
}
public async void Send<T>(CmdType cmdId, T data) where T : class
{
var packet = new NetPacket()
{
CmdId = (int)cmdId,
Data = data
};
var buffer = Unpooled.Buffer();
packet.Serialize<T>(buffer);
packet.Buf = buffer;
await _channel.WriteAndFlushAsync(packet);
}
}
}