first commit

This commit is contained in:
2026-09-02 16:31:50 +08:00
commit a461727193
911 changed files with 692450 additions and 0 deletions
@@ -0,0 +1,59 @@
using DotNetty.Buffers;
using DotNetty.Codecs;
using DotNetty.Transport.Channels;
using JSMachine.WMS.Infrastructure.Helper;
using JSMachine.WMS.Netty.NettyAsClient.Command;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Text;
namespace JSMachine.WMS.Netty.NettyAsClient.Codec
{
public class Decoder : ByteToMessageDecoder
{
protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List<object> output)
{
if (input != null)
{
int length = input.ReadableBytes;
byte[] bytes = new byte[length];
string msg = Encoding.UTF8.GetString(bytes);
LogHelper.Info(msg);
output.Add(input);
try
{
//IMessagePackage message = MessagePackageMange.Instance.BinaryDeserializeToObject(bytes);
//IMessagePackage message = JsonConvert.DeserializeObject<IMessagePackage>(Encoding.UTF8.GetString(bytes));
string json = Encoding.UTF8.GetString(bytes);
JObject jobj = JObject.Parse(json);
//当找不到这个节点的值的时候则自动赋0,因此,命令类型不可以是0,否则无法解析的命令都自动归为0类型了
//Common.MessagePack.CommandType cmdType = (Common.MessagePack.CommandType)jobj.Value<int>("ComType");
//switch (cmdType)
//{
// case Common.MessagePack.CommandType.g_eKeepAlive:
// baseCmd = JsonConvert.DeserializeObject<HeartBeartCmd>(json);
// break;
// default:
// break;
//}
//output.Add(baseCmd);
}
catch (Exception ex)
{
LogHelper.Error($"解码远程地址:{context.Channel.RemoteAddress}----发送的数据异常");
}
input.Clear();
}
}
}
}
@@ -0,0 +1,39 @@
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}");
}
}
}
}
@@ -0,0 +1,39 @@
using DotNetty.Buffers;
using DotNetty.Codecs;
using DotNetty.Transport.Channels;
using JSMachine.WMS.Infrastructure.Helper;
using JSMachine.WMS.Netty.NettyAsClient.Command;
using Newtonsoft.Json;
using System;
using System.Text;
namespace JSMachine.WMS.Netty.NettyAsClient.Codec
{
public class Encoder : MessageToByteEncoder<string>
{
private string _encoderWord;
public Encoder():base() { }
public Encoder(string encoderWord)
{
_encoderWord= encoderWord;
}
protected override void Encode(IChannelHandlerContext context, string message, IByteBuffer output)
{
try
{
byte[] body = Encoding.UTF8.GetBytes(message);
byte[] tail = Encoding.UTF8.GetBytes(_encoderWord);
output.WriteBytes(body);
output.WriteBytes(tail);
}
catch (Exception ex)
{
LogHelper.Error($"TCP编码异常,异常信息 {ex.Message}");
}
}
}
}