Beispiel #1
0
        /// <summary>
        /// 发送到监听者
        /// </summary>
        /// <param name="message">消息</param>
        public virtual void SendToListener(CMessage message)
        {
            MessageListener listener = null;

            lock (m_listeners)
            {
                if (m_listeners.ContainsKey(message.m_requestID))
                {
                    listener = m_listeners[message.m_requestID];
                }
            }
            if (listener != null)
            {
                listener.CallBack(message);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 注册数据监听
 /// </summary>
 /// <param name="requestID">请求ID</param>
 /// <param name="callBack">回调函数</param>
 public virtual void RegisterListener(int requestID, ListenerMessageCallBack callBack)
 {
     lock (m_listeners)
     {
         MessageListener listener = null;
         if (!m_listeners.ContainsKey(requestID))
         {
             listener = new MessageListener();
             m_listeners[requestID] = listener;
         }
         else
         {
             listener = m_listeners[requestID];
         }
         listener.Add(callBack);
     }
 }