示例#1
0
        /// <summary>
        /// 发送到监听者
        /// </summary>
        /// <param name="message">消息</param>
        public virtual void sendToListener(FCMessage message)
        {
            FCMessageListener listener = null;

            lock (m_listeners) {
                if (m_listeners.containsKey(message.m_requestID))
                {
                    listener = m_listeners.get(message.m_requestID);
                }
            }
            if (listener != null)
            {
                listener.callBack(message);
            }
        }
示例#2
0
 /// <summary>
 /// 注册数据监听
 /// </summary>
 /// <param name="requestID">请求ID</param>
 /// <param name="callBack">回调函数</param>
 public virtual void registerListener(int requestID, ListenerMessageCallBack callBack)
 {
     lock (m_listeners) {
         FCMessageListener listener = null;
         if (!m_listeners.ContainsKey(requestID))
         {
             listener = new FCMessageListener();
             m_listeners.put(requestID, listener);
         }
         else
         {
             listener = m_listeners.get(requestID);
         }
         listener.add(callBack);
     }
 }