public void PacketArrived(TcpServer TS) { string ServiceId = TS.ServiceID; ConcurrentQueue <TcpReceivedData> Qtrd = TS.TQ.Qtrd; List <TcpSocket> Ts = TS.Ts; ConcurrentQueue <TcpSendData> Qtsd = TS.TQ.Qtsd; while (Qtrd.Count > 0) { TcpReceivedData trd = null; Qtrd.TryDequeue(out trd); if (trd != null) { try { //注册&透传 Service.ServiceBussiness.RemoteCommand(trd.Data); //Service.ServiceBussiness.Registered30(urd.Data); //ASCII To String string data = EnCoder.ByteArrayToHexStr(trd.Data); //Encoding.ASCII.GetString(trd.Data); if (pd.GetDataState(data) == "01") { string STCD = pd.GetCode(data); InsertNewSTCD(STCD, Service.ServiceEnum.NFOINDEX.TCP, TS); bool B = false; //更新socket列表的stcd、socket TcpBussiness.UpdSocket(TS, trd.SOCKET, STCD, out B); if (!B) { //上线 TcpBussiness.TcpConnected(TS, STCD); } //通知界面 ServiceBussiness.WriteQUIM("TCP", ServiceId, STCD, "接收数据", trd.Data, Service.ServiceEnum.EnCoderType.ASCII, Service.ServiceEnum.DataType.Text); PacketArrived(data, ServiceEnum.NFOINDEX.TCP, TS); } else { ServiceBussiness.WriteQUIM("TCP", ServiceId, "", "接收异常数据", trd.Data, Service.ServiceEnum.EnCoderType.ASCII, Service.ServiceEnum.DataType.Text); } } catch (Exception ex) { //通知界面 ServiceBussiness.WriteQUIM("TCP", ServiceId, "", "接收异常数据", trd.Data, Service.ServiceEnum.EnCoderType.ASCII, Service.ServiceEnum.DataType.Text); log.Error(DateTime.Now + "包处理操作异常" + ex.ToString()); } } } }
public void PacketArrived(TcpService.TcpServer TS) { string ServiceId = TS.ServiceID; ConcurrentQueue <TcpReceivedData> Qtrd = TS.TQ.Qtrd; List <TcpSocket> Ts = TS.Ts; ConcurrentQueue <TcpSendData> Qtsd = TS.TQ.Qtsd; while (Qtrd.Count > 0) { TcpReceivedData trd = null; Qtrd.TryDequeue(out trd); if (trd != null) { //Frame[] frames = null; try { //注册&透传 Service.ServiceBussiness.RemoteCommand(trd.Data); //Service.ServiceBussiness.Registered30(urd.Data); //ASCII To String string STR = Encoding.ASCII.GetString(trd.Data); string[] STRs = STR.Split(new string[] { "##" }, StringSplitOptions.None); if (STRs.Length > 0) { foreach (var item in STRs) { if (item != "") { string STCD = pd.GetMN(item); InsertNewSTCD(STCD, Service.ServiceEnum.NFOINDEX.TCP, TS); bool B = false; //更新socket列表的stcd、socket TcpBussiness.UpdSocket(TS, trd.SOCKET, STCD, out B); if (!B) { //上线 TcpBussiness.TcpConnected(TS, STCD); } //通知界面 ServiceBussiness.WriteQUIM("TCP", ServiceId, STCD, "接收数据", trd.Data, Service.ServiceEnum.EnCoderType.ASCII, Service.ServiceEnum.DataType.Text); PacketArrived(item, ServiceEnum.NFOINDEX.TCP, TS); } } } else { ServiceBussiness.WriteQUIM("TCP", ServiceId, "", "接收异常数据", trd.Data, Service.ServiceEnum.EnCoderType.ASCII, Service.ServiceEnum.DataType.Text); } } catch (Exception ex) { //通知界面 ServiceBussiness.WriteQUIM("TCP", ServiceId, "", "接收异常数据", trd.Data, Service.ServiceEnum.EnCoderType.ASCII, Service.ServiceEnum.DataType.Text); log.Error(DateTime.Now + "包处理操作异常" + ex.ToString()); } } } //throw new NotImplementedException(); }