예제 #1
0
        /// <summary>
        /// 从缓冲池里获得一个对象
        /// </summary>
        /// <returns></returns>
        public static NetTaskT <T> AcquireContent(ushort packetId)
        {
            var ret = TaskPool.AcquireContent();

            ret.isRelease   = false;
            ret.TaskProfile = NetTaskProfile.GetNetTaskProfile(packetId);
            ret.RecvTime    = OneServer.NowTime;
            ret._packetId   = packetId;
            return(ret);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="iPacketID"></param>
        /// <param name="priority"></param>
        /// <param name="onPacketReceive"></param>
        public void Register(ushort iPacketID, PacketPriority priority, Action <T, PacketReader> onPacketReceive)
        {
            if (m_Handlers[iPacketID] != null)
            {
                Logs.Warn("Msgid {0} is replace.", iPacketID);
            }

            NetTaskProfile.GetNetTaskProfile(iPacketID);

            m_Handlers[iPacketID] = new PacketHandlerT <T>(iPacketID, priority, onPacketReceive);
        }
예제 #3
0
        /// <summary>
        /// 任务类型
        /// </summary>
        /// <param name="iPacketID"></param>
        /// <param name="taskType"></param>
        /// <param name="onPacketReceive"></param>
        public void Register(ushort iPacketID, TaskType taskType, Action <T, PacketReader> onPacketReceive)
        {
            if (m_Handlers[iPacketID] != null)
            {
                //  如果有注册相同的消息id,这里只是进行记录,并不干预运行
                Logs.Warn("Msgid {0} is replace.", iPacketID);
            }

            //  这里在初始化的时候就把对应的性能监视的对象给创建好
            NetTaskProfile.GetNetTaskProfile(iPacketID);

            m_Handlers[iPacketID] = new PacketHandlerT <T>(iPacketID, PacketPriority.Normal, taskType, onPacketReceive);
        }