/// <summary> /// Process an ANP message received from the WM. /// </summary> private void ProcessWmAnpMsg(KcmAnpMsg msg) { // Ignore messages not destined to connected KASes. if (!m_kasTree.ContainsKey(msg.KasID)) return; KcmKas kas = m_kasTree[msg.KasID]; if (kas.ConnStatus != KcmKasConnectionStatus.Connected) return; // Enqueue the message. kas.SendQueue.Enqueue(msg.Msg); }
/// <summary> /// Send an ANP message to a KAS. /// </summary> public void SendAnpMsgToKcm(KcmAnpMsg m) { lock (m_mutex) { m_ToKcmAnpMsgArray.Add(m); NotifyKcm(); } }
/// <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); } }