using DotNetty.Buffers;
using DotNetty.Codecs;
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Utils;
using log4net;
using Service.Charger.Client;
using Service.Charger.Msg;
namespace Service.Charger.Codec
{
///
///
///
public class Encoder : MessageToByteEncoder
{
private static readonly ILog Log = LogManager.GetLogger(typeof(Encoder));
///
///
///
///
///
///
protected override void Encode(IChannelHandlerContext context, ASDU obj, IByteBuffer output)
{
byte[] bytes = obj.ToBytes();
List list = new List(bytes);
byte[] result = list.ToArray();
Log.Info($"send {BitUtls.BytesToHexStr(result)}");
output.WriteBytes(result);
}
}
}