/// <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)); }
/// <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; } }