Beispiel #1
0
 /// <summary>
 /// Send an ANP message to a KCD.
 /// </summary>
 public void SendAnpMsgToKcd(KcdAnpMsg m)
 {
     lock (m_mutex)
     {
         m_toThreadAnpMsgArray.Add(m);
         NotifyKcdThread();
     }
 }
Beispiel #2
0
        /// <summary>
        /// Process an ANP message received from the KCD.
        /// </summary>
        private static void ProcessKcdAnpMsg(KcdAnpMsg m)
        {
            KLogging.Log("ProcessKcdAnpMsg() called");

            // We're stopping. Bail out.
            if (StopFlag)
            {
                return;
            }

            // The KCD specified does not exist. Bail out.
            if (!Wm.KcdTree.ContainsKey(m.KcdID))
            {
                return;
            }

            // The KCD is not connected. Bail out.
            WmKcd kcd = Wm.KcdTree[m.KcdID];

            if (kcd.ConnStatus != KcdConnStatus.Connected)
            {
                return;
            }

            // Process the message according to its type.
            try
            {
                if (m.Msg.Type == KAnp.KANP_RES_FAIL && m.Msg.Elements[0].UInt32 == KAnp.KANP_RES_FAIL_BACKEND)
                {
                    throw new Exception("backend error: " + m.Msg.Elements[1].String);
                }
                else if (m.IsReply())
                {
                    ProcessKcdAnpReply(kcd, m.Msg);
                }
                else if (m.IsEvent())
                {
                    ProcessKcdAnpEvent(kcd, m.Msg);
                }
                else
                {
                    throw new Exception("received unexpected ANP message type (" + m.Msg.Type + ")");
                }
            }

            catch (Exception ex)
            {
                HandleTroublesomeKcd(kcd, ex);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Process an ANP message received from the WM.
        /// </summary>
        private void ProcessWmAnpMsg(KcdAnpMsg msg)
        {
            // Ignore messages not destined to connected KCDs.
            if (!m_kcdTree.ContainsKey(msg.KcdID))
            {
                return;
            }
            KcdThreadHost kcd = m_kcdTree[msg.KcdID];

            if (kcd.ConnStatus != KcdThreadConnStatus.Connected)
            {
                return;
            }

            // Enqueue the message.
            kcd.SendQueue.Enqueue(msg.Msg);
        }
Beispiel #4
0
        /// <summary>
        /// Process an ANP message received from the KCD.
        /// </summary>
        private static void ProcessKcdAnpMsg(KcdAnpMsg m)
        {
            KLogging.Log("ProcessKcdAnpMsg() called");

            // We're stopping. Bail out.
            if (StopFlag) return;

            // The KCD specified does not exist. Bail out.
            if (!Wm.KcdTree.ContainsKey(m.KcdID)) return;

            // The KCD is not connected. Bail out.
            WmKcd kcd = Wm.KcdTree[m.KcdID];
            if (kcd.ConnStatus != KcdConnStatus.Connected) return;

            // Process the message according to its type.
            try
            {
                if (m.Msg.Type == KAnp.KANP_RES_FAIL && m.Msg.Elements[0].UInt32 == KAnp.KANP_RES_FAIL_BACKEND)
                    throw new Exception("backend error: " + m.Msg.Elements[1].String);
                else if (m.IsReply()) ProcessKcdAnpReply(kcd, m.Msg);
                else if (m.IsEvent()) ProcessKcdAnpEvent(kcd, m.Msg);
                else throw new Exception("received unexpected ANP message type (" + m.Msg.Type + ")");
            }

            catch (Exception ex)
            {
                HandleTroublesomeKcd(kcd, ex);
            }
        }
Beispiel #5
0
 /// <summary>
 /// Send an ANP message to a KCD.
 /// </summary>
 public void SendAnpMsgToKcd(KcdAnpMsg m)
 {
     lock (m_mutex)
     {
         m_toThreadAnpMsgArray.Add(m);
         NotifyKcdThread();
     }
 }
Beispiel #6
0
        /// <summary>
        /// Process an ANP message received from the WM.
        /// </summary>
        private void ProcessWmAnpMsg(KcdAnpMsg msg)
        {
            // Ignore messages not destined to connected KCDs.
            if (!m_kcdTree.ContainsKey(msg.KcdID)) return;
            KcdThreadHost kcd = m_kcdTree[msg.KcdID];
            if (kcd.ConnStatus != KcdThreadConnStatus.Connected) return;

            // Enqueue the message.
            kcd.SendQueue.Enqueue(msg.Msg);
        }