示例#1
0
        public void RemoveCallback <T>(Action <T> proc) where T : BaseMessage
        {
            var           n = protoName2ProtoID <T>();
            IProtoHandler iph;

            if (sdict.TryGetValue(n, out iph))
            {
                ProtoHandler <T> pht = iph as ProtoHandler <T>;
                pht.OnReceive -= proc;
            }
        }
示例#2
0
        public void AddCallback <T>(Action <T> proc) where T : BaseMessage
        {
            var           n = protoName2ProtoID <T>();
            IProtoHandler iph;
            bool          b = sdict.TryGetValue(n, out iph);

            if (b)
            {
                ProtoHandler <T> pht = iph as ProtoHandler <T>;
                pht.OnReceive -= proc;
                pht.OnReceive += proc;
            }
            else
            {
                ProtoHandler <T> pht = new ProtoHandler <T>();
                sdict.Add(n, pht);
                pht.OnReceive -= proc;
                pht.OnReceive += proc;
            }
        }