You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
784 B

using DotNetty.Buffers;
using DotNetty.Codecs;
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Utils;
using log4net;
using Service.WaterCool.Msg;
namespace Service.WaterCool.Codec;
/// <summary>
///
/// </summary>
public class Encoder : MessageToByteEncoder<BaseMsg>
{
private static readonly ILog Log = LogManager.GetLogger(typeof(Encoder));
protected override void Encode(IChannelHandlerContext context, BaseMsg obj, IByteBuffer output)
{
byte[] bytes = obj.ToBytes();
byte[] result =
{ 0x88, bytes[3], bytes[2], bytes[1], bytes[0], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], bytes[10], bytes[11] };
Log.Info($"send={BitUtls.BytesToHexStr(result)}");
output.WriteBytes(result); }
}