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.

30 lines
790 B

using DotNetty.Buffers;
using DotNetty.Codecs;
using DotNetty.Transport.Channels;
using log4net;
6 months ago
using Service.Car.Common;
using Service.Car.Msg;
namespace Service.Car.Codec;
/// <summary>
///
/// </summary>
public class Encoder : MessageToByteEncoder<BaseMsg>
{
private static readonly ILog Log = LogManager.GetLogger(typeof(Encoder));
/// <summary>
///
/// </summary>
/// <param name="context"></param>
/// <param name="obj"></param>
/// <param name="output"></param>
protected override void Encode(IChannelHandlerContext context, BaseMsg obj, IByteBuffer output)
{
byte[] bytes = obj.ToBytes();
List<byte> list = new List<byte>(bytes);
list.AddRange(CarConst.EndChar);
output.WriteBytes(list.ToArray());
}
}