示例#1
0
        /// <summary>
        /// Process an ANP message received from the KCM.
        /// </summary>
        private void ProcessKcmAnpMsg(KcmAnpMsg m)
        {
            Logging.Log("ProcessKcmAnpMsg() called");

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

            // The KAS specified does not exist. Bail out.
            if (!m_wm.KasTree.ContainsKey(m.KasID)) return;

            // The KAS is not connected. Bail out.
            WmKas kas = m_wm.KasTree[m.KasID];
            if (kas.ConnStatus != KasConnStatus.Connected) return;

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

            catch (Exception ex)
            {
                HandleTroublesomeKas(kas, ex);
            }
        }