first commit
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JSMachine.WMS.Netty.Common.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// TCP引擎初始化参数
|
||||
/// </summary>
|
||||
public class TcpEngineInitParam
|
||||
{
|
||||
/// <summary>
|
||||
/// TCP服务IP
|
||||
/// </summary>
|
||||
public string IP { get; set; }
|
||||
/// <summary>
|
||||
/// TCP服务端口
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
/// <summary>
|
||||
/// 设备类型
|
||||
/// </summary>
|
||||
public DeviceType DeviceType { get; set; }
|
||||
/// <summary>
|
||||
/// 最小条码长度(用于区分条码和其他数据),若数据包解析后小于该长度则视为读码失败
|
||||
/// </summary>
|
||||
public int MinCodeLength { get; set; }
|
||||
/// <summary>
|
||||
/// 编码字符
|
||||
/// </summary>
|
||||
public string EncoderWord { get; set; }
|
||||
/// <summary>
|
||||
/// 解码字符
|
||||
/// </summary>
|
||||
public string DecoderWord { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设备类型
|
||||
/// </summary>
|
||||
public enum DeviceType
|
||||
{
|
||||
/// <summary>
|
||||
/// 基恩士
|
||||
/// </summary>
|
||||
KeyEnce = 0,
|
||||
/// <summary>
|
||||
/// 倍加福
|
||||
/// </summary>
|
||||
PepperlAndFuchs = 1,
|
||||
/// <summary>
|
||||
/// 喷墨打印机
|
||||
/// </summary>
|
||||
PenmoPrint= 2
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using DotNetty.Transport.Channels;
|
||||
using System.Net;
|
||||
|
||||
namespace JSMachine.WMS.Netty.Common.Util
|
||||
{
|
||||
public static class ChannelHandlerContextUtil
|
||||
{
|
||||
public static IPInfo ToIPInfo(this IChannelHandlerContext channel, AddressOnwer addressOnwer)
|
||||
{
|
||||
IPEndPoint iPAddress = addressOnwer == AddressOnwer.Local ? (IPEndPoint)channel.Channel.LocalAddress
|
||||
: (IPEndPoint)channel.Channel.RemoteAddress;
|
||||
string ip = iPAddress?.Address.MapToIPv4().ToString();
|
||||
int port = iPAddress == null ? 0 : iPAddress.Port;
|
||||
|
||||
return new IPInfo { IP = ip, Port = port };
|
||||
}
|
||||
}
|
||||
|
||||
public class IPInfo
|
||||
{
|
||||
public string IP { get; set; }
|
||||
public int Port { get; set; }
|
||||
}
|
||||
|
||||
public enum AddressOnwer
|
||||
{
|
||||
Local = 0,
|
||||
Remote = 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user