/******************************************************************** * * * * 创建时间:2014-08-05 * * 说明:客户端信息类,存储客户端的一些基本信息,可定义修改 * * ********************************************************************/ using NetWorkHelper.IUser; using NetWorkHelper.TClass; using System.Collections.Generic; using System.Net; using System.Net.Sockets; namespace NetWorkHelper.IModels { public class IClient { public IClient() { ClientStyle = ClientStyle.PcSocket; Username = ""; Password = ""; BufferInfo = new BufferInfo(); ClientInfo = new ClientInfo(); } public IClient(Socket socket) { WorkSocket = socket; if (socket != null) { Ip = ((IPEndPoint)WorkSocket.RemoteEndPoint).Address.ToString(); Port = ((IPEndPoint)WorkSocket.RemoteEndPoint).Port; } ClientStyle = ClientStyle.PcSocket; Username = ""; Password = ""; BufferInfo = new BufferInfo(); ClientInfo = new ClientInfo(); } /// /// Socket /// public Socket WorkSocket { get; set; } /// /// 客户端端口IP /// public string Ip { get; set; } /// /// 客户端端口 /// public int Port { get; set; } /// /// Socket类型(网页版或者PC版) /// public ClientStyle ClientStyle { get; set; } /// /// 客户端登录账号 /// public string Username { get; set; } /// /// 客户端登录密码 /// public string Password { get; set; } /// /// 客户端信息类 /// public ClientInfo ClientInfo { get; set; } /// /// 数据缓存区信息 /// public BufferInfo BufferInfo { get; set; } /// /// 自定义数据 /// public object CustomData { get; set; } /// /// 是否已登录 /// public bool IsLogin { get; set; } } public class ClientInfo { /// /// 心跳检测模式 /// public HeartCheckType HeartCheckType = HeartCheckType.EncodingString; /// /// 心跳包数组数据【如果长度为0为空则不发送心跳包】 /// public byte[] HeartbeatByte = new byte[0]; /// /// 心跳包字符串【如果为空则不发送心跳包】 /// public string Heartbeat = ""; /// /// 客户端ID /// public int ClientId { get; set; } /// /// 客户端编号 /// public string ClientNo { get; set; } /// /// 客户端类型 /// public ClientType Clienttype = ClientType.None; /// /// 若是小车类型,则该标示表示小车单前的RFID卡号 /// public string ClientRfidNo = ""; /// /// 若是小车类型,则该标示表示小车单前的车道号 /// public string ClientLaneNo = ""; /// /// 如果是小车类型,则该项用于存储车辆运动状态,默认:运动 /// public VehicleMotionState VehicleMotionState = VehicleMotionState.Running; /// /// 判断在停车位上的状态 /// public SitState SitState = SitState.None; /// /// 如果是信号机类型,用来存储信号灯路口状态 /// public LedState[] SingleState = new LedState[0]; /// /// 如果是信号机类型,用来存储信号灯人行道状态 /// public LedState[] SidewalkState = new LedState[0]; /// /// 如果是闸机,升降杆客户端,(用于存储各个控制端的状态) /// public byte[] MotorClientState = new byte[32]; /// /// 是否授权 /// public bool IsAuthorization { get; set; } /// /// 指令操作类型 /// public string OrderType = ""; /// /// 如果是调度系统客户端,则用来存储PC客户端当前需要订阅的车辆列表 /// public List CarNo { get; set; } } public class BufferInfo { //备份缓冲区 private byte[] _bufferBackup = null; /// /// 备份缓冲区;动态增大或缩小缓冲区的时候用到; /// internal byte[] BufferBackup { get { return _bufferBackup; } set { _bufferBackup = value; } } /// /// 接收缓冲区 /// public byte[] ReceivedBuffer = new byte[2048]; /// /// 发送缓冲区 /// public byte[] SendBuffer = new byte[1024]; /// /// 接收的字符串信息 /// public string RecevidMsg = ""; } /// /// 心跳检测模式 /// public enum HeartCheckType { /// /// 字符串模式 /// EncodingString, /// /// 十六进制字符串 /// HexString, /// /// byte数组模式 /// Byte } }