Exemplo n.º 1
0
        }         // ThreadProc

        public void NetLoop()
        {
            bool bDone = false, bRes = true;;

            Byte[] abReceived = null;
            RMMsg  rmMsg      = null;

            while (!bDone)
            {
                try
                {
                    // Wait for UDP message
                    abReceived = m_receivingUdpClient.Receive(ref m_IPEndPoint);

                    // Copy data to a RM msg, push it to worker thread, and Ack-Received.
                    rmMsg = new RMMsg(m_IPEndPoint, abReceived);
                    m_aqMsgIn.Push(rmMsg);

                    bRes = SendAckReceived(rmMsg);

                    rmMsg      = null;
                    abReceived = null;
                }
                catch (Exception exc)
                {
                    m_Logger.Log(exc);
                }
            }
        }         // NetLoop
Exemplo n.º 2
0
        }         // ThreadProc

        public void MsgLoop()
        {
            bool   bDone = false, bRes = true;
            RMMsg  rmMsg = null;
            XmlMsg xMsg  = null;

            while (!bDone)
            {
                try
                {
                    rmMsg = (RMMsg)(m_aqMsgIn.Pop());
                    xMsg  = XmlMsg.Parse(rmMsg.m_sMsgDecoded);

                    switch (xMsg.MsgType)
                    {
                    case XmlMsg.eMsgTypes.Ack:
                    case XmlMsg.eMsgTypes.NOP:
                    case XmlMsg.eMsgTypes.Ping:
                    {                                   // All messages we can ignore
                    }
                    break;

                    case XmlMsg.eMsgTypes.SBResetComp:
                    {
                        bRes = ResetSBComponents(xMsg);
                    }
                    break;

                    default:
                    {
                        m_Logger.Log(Level.Warning, string.Format("LRMWorkerThread.MsgLoop: Unsupported msg type: {0}.{1}", xMsg.MsgType.ToString(), xMsg.MsgType));
                    }
                    break;
                    }

                    xMsg  = null;
                    rmMsg = null;
                }
                catch (Exception exc)
                {
                    m_Logger.Log(exc);
                }
            }
        }         // MsgLoop
Exemplo n.º 3
0
        }         // NetLoop

        public bool SendAckReceived(RMMsg i_Msg)
        {
            bool bRet = true;

            Byte[] abMsg = null;
            int    iSeqNum = -1;
            int    iStart = -1, iEnd = -1;
            int    iRes = 0;
            XmlMsg xMsg = null;

            try
            {
                iStart = i_Msg.m_sMsgDecoded.IndexOf("<" + XmlMsg.eMsgTags.SeqNum.ToString() + ">") + XmlMsg.eMsgTags.SeqNum.ToString().Length + 2;
                iEnd   = i_Msg.m_sMsgDecoded.IndexOf("</" + XmlMsg.eMsgTags.SeqNum.ToString() + ">");

                if ((iStart < 0) || (iEnd < 1))
                {
                    m_Logger.Log(Level.Exception, "UdpMsgListenerThread.SendAckReceived: SeqNum tags not found.");
                }
                else
                {
                    iSeqNum = int.Parse(i_Msg.m_sMsgDecoded.Substring(iStart, (iEnd - iStart)));

                    xMsg         = new XmlMsg();
                    xMsg.MsgType = XmlMsg.eMsgTypes.Ack;
                    xMsg.SeqNum  = iSeqNum;
                    abMsg        = Encoding.ASCII.GetBytes(xMsg.ToString());                                                    // FIX - Should this be UTF8?

                    iRes = m_receivingUdpClient.Send(abMsg, abMsg.Length, i_Msg.m_EP);
                }
            }
            catch (Exception exc)
            {
                bRet = false;
                m_Logger.Log(exc);
            }

            return(bRet);
        } // SendAckReceived