Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="nID"></param>
        /// <param name="data"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public static bool HandleMsg(int nID, byte[] data, int count)
        {
            TCPHandleMsgDelegate msgDelegate = FindMsgDelegate(nID & 0xff00);

            if (msgDelegate == null)
            {
                //未注册得时间
                return(false);
            }

            return(msgDelegate(nID & 0x00ff, data, count));
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        public static void AddMsgDelegate(int nID, TCPHandleMsgDelegate msgDelegate)
        {
            TCPHandleMsgDelegate tryMsgDelegate;

            if (!TCPHandleMsgDelegateDict.TryGetValue(nID, out tryMsgDelegate))
            {
                TCPHandleMsgDelegateDict.Add(nID, msgDelegate);
            }
            else
            {
                tryMsgDelegate += msgDelegate;
            }
        }