Files
ww-jst/wmsjst/JSMachine.WMS.Netty/NettyAsClient/Codec/EnCoderPrint.cs
T
2026-09-02 16:31:50 +08:00

40 lines
1.0 KiB
C#

using DotNetty.Buffers;
using DotNetty.Codecs;
using DotNetty.Transport.Channels;
using JSMachine.WMS.Infrastructure.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JSMachine.WMS.Netty.NettyAsClient.Codec
{
public class EnCoderPrint : MessageToByteEncoder<byte[]>
{
private string _encoderWord;
public EnCoderPrint() : base() { }
public EnCoderPrint(string encoderWord)
{
_encoderWord = encoderWord;
}
protected override void Encode(IChannelHandlerContext context, byte[] message, IByteBuffer output)
{
try
{
byte[] body = message;
//byte[] tail = Encoding.UTF8.GetBytes(_encoderWord);
output.WriteBytes(body);
//output.WriteBytes(tail);
}
catch (Exception ex)
{
LogHelper.Error($"TCP编码异常,异常信息 {ex.Message}");
}
}
}
}