/// <summary>
        /// 过滤器后 进入该方法
        /// </summary>
        /// <param name="session"></param>
        /// <param name="requestInfo"></param>
        protected override void ExecuteCommand(UdpSession session, MyUdpRequestInfo requestInfo)
        {
            if (requestInfo.Key.Contains(HandleUdpUtils.C_SESSION_KEY) ||
                requestInfo.Key.Contains(HandleUdpUtils.H_SESSION_KEY) ||
                requestInfo.Key.Contains(HandleUdpUtils.T_SESSION_KEY))
            {
                if (requestInfo.TerminalCounterData.TranType == 10)
                {
                    LogHelper.WriteLog(DateTime.Now.ToString() + "  " + requestInfo.Key + ": HeartBeat success  " + session.NickName);
                    string strReaderCode = requestInfo.TerminalCounterData.ReaderID;


                    string SnDate = string.Format("{0:yyyyMMddHHmmssffff}", DateTime.Now).Substring(3, 10);

                    string strHeartbeat = string.Empty;
                    strHeartbeat += "at=TDATA";                                                                           //-----1  数据类型 ---
                    strHeartbeat += ("&sn=" + (SnDate));                                                                  //-----1 通信序列号---
                    strHeartbeat += ("&ti=" + (strReaderCode));                                                           //-----1 reader id----
                    strHeartbeat += ("&lst=" + (string.Format("{0:yyyyMMddHHmmssffff}", DateTime.Now).Substring(0, 14))); //-1 最终shot 时间---
                    strHeartbeat += ("&ip=" + (VarGlobal.DeviceIP));                                                      //---1 通信接收时间--生成此命令时间
                    LogHelper.WriteLog("Heart " + requestInfo.Key + "~" + requestInfo.SessionID + "~" + strHeartbeat);
                    try
                    {
                        CounterSendMsg cntMsg = new CounterSendMsg();
                        cntMsg.bMultiFlag = false;
                        cntMsg.strSendMsg = strHeartbeat;
                        //startThreadSend(cntMsg);//Heart data
                        Task task = Task.Factory.StartNew(() => ClientPost(strHeartbeat));
                    }
                    catch (OutOfMemoryException ex)
                    {
                        LogHelper.WriteLog("OutOfMemoryException   10 Code" + ex.ToString());
                    }
                    catch (Exception ex)
                    {
                        string strex = ex.ToString();
                        AppLog.Error(requestInfo.SessionID + " 10 Code " + strex);
                        LogHelper.WriteLog("Exception   10 Code" + ex.ToString());
                    }
                }
                else if (requestInfo.TerminalCounterData.TranType == 46)
                {
                    LogHelper.WriteLog("Normal " + requestInfo.Key + "~" + requestInfo.SessionID + "~  " + session.NickName + "  ~  " + requestInfo.TerminalCounterData.allParams);
                    try
                    {
                        //strbuf46 = (m_strOneIDAllParam + "=============radio = 3  启动线程=== single ==========");
                        //showApiData(VarGlobal.TokenKey, richApiLog);
                        //showApiData(strbuf46, richApiLog);
                        CounterSendMsg cntMsg = new CounterSendMsg();
                        cntMsg.bMultiFlag = false;
                        cntMsg.strSendMsg = requestInfo.TerminalCounterData.allParams;
                        //startThreadSend(cntMsg);//Counter Data
                        Task task = Task.Factory.StartNew(() => ClientPost(requestInfo.TerminalCounterData.allParams));
                    }
                    catch (OutOfMemoryException ex)
                    {
                        LogHelper.WriteLog("OutOfMemoryException   10 Code" + ex.ToString());
                    }
                    catch (Exception ex)
                    {
                        string strex = ex.ToString();
                        AppLog.Error(requestInfo.SessionID + " 46 Code " + strex);
                        LogHelper.WriteLog("Exception   46 Code" + ex.ToString());
                        //WriteLogFileName(strex, "StartThreadToSend");
                        //return -5;
                    }
                }
                else
                {
                    LogHelper.WriteLog("Error " + requestInfo.Key + "~" + requestInfo.SessionID + "~" + requestInfo.TerminalCounterData.allParams);
                }
                //if (requestInfo.Key.Contains("0123456"))
                //{
                //    session.Send("Server receive success - " + requestInfo.Key);
                //}
                //session.Send("hello");
            }
            else
            {
                LogHelper.WriteLog(requestInfo.SessionID + "不存在该设备");
            }
        }
 protected override void OnStarted()
 {
     //启动成功
     LogHelper.WriteLog(string.Format("UDP Socket启动成功:{0}:{1}", this.Config.Ip, this.Config.Port));
 }
示例#3
0
 void app_NewSessionConnected(UdpSession session)
 {
     LogHelper.WriteLog("新链接:" + session.SessionID);
 }
        public static ConcurrentDictionary <string, VideoPackageModel> FILE_WRITERS = new ConcurrentDictionary <string, VideoPackageModel>(); //读取文件

        protected override void OnSystemMessageReceived(string messageType, object messageData)
        {
            LogHelper.WriteLog(string.Format("Udp server Receive:{0}:{1}", messageType, messageData));
            Console.WriteLine(messageType);
            base.OnSystemMessageReceived(messageType, messageData);
        }
示例#5
0
 void app_SessionClosed(UdpSession session, SuperSocket.SocketBase.CloseReason value)
 {
     LogHelper.WriteLog("链接断开:" + session.SessionID);
 }