/// <summary> /// /// </summary> /// <param name="iPacketID"></param> /// <param name="priority"></param> /// <param name="onPacketReceive"></param> public void Register(ushort iPacketID, PacketPriority priority, PacketReceiveCallback onPacketReceive) { if (m_Handlers[iPacketID] != null) { Logs.Warn("Msgid {0} is replace.", iPacketID); } NetTaskProfile.GetNetTaskProfile(iPacketID); m_Handlers[iPacketID] = new PacketHandler(iPacketID, priority, onPacketReceive); }
/// <summary> /// 任务类型 /// </summary> /// <param name="iPacketID"></param> /// <param name="taskType"></param> /// <param name="onPacketReceive"></param> public void Register(ushort iPacketID, TaskType taskType, PacketReceiveCallback onPacketReceive) { if (m_Handlers[iPacketID] != null) { // 如果有注册相同的消息id,这里只是进行记录,并不干预运行 Logs.Warn("Msgid {0} is replace.", iPacketID); } // 这里在初始化的时候就把对应的性能监视的对象给创建好 NetTaskProfile.GetNetTaskProfile(iPacketID); m_Handlers[iPacketID] = new PacketHandler(iPacketID, PacketPriority.Normal, taskType, onPacketReceive); }
/// <summary> /// /// </summary> /// <param name="iPacketID"></param> /// <param name="priority"></param> /// <param name="onPacketReceive"></param> public void Register(ushort iPacketID, PacketPriority priority, PacketReceiveCallback onPacketReceive) { m_Handlers[iPacketID] = new PacketHandler(iPacketID, priority, onPacketReceive); }
/// <summary> /// 注册数据包的处理调用者 /// 注意,如果存在相同的消息id,会进行调用方法的替换操作 /// </summary> /// <param name="iPacketID"></param> /// <param name="onPacketReceive"></param> public void Register(ushort iPacketID, PacketReceiveCallback onPacketReceive) { if (m_Handlers[iPacketID] != null) { // 如果有注册相同的消息id,这里只是进行记录,并不干预运行 Logs.Warn("Msgid {0} is replace.", iPacketID); } m_Handlers[iPacketID] = new PacketHandler(iPacketID, PacketPriority.Normal, onPacketReceive); }
/// <summary> /// 压入数据包至优先级处理列表 /// </summary> public void Enqueue(PacketHandler packetHandler, PacketReader packetReader) { PacketExecuteInfo packetExecuteInfo = new PacketExecuteInfo { PacketHandler = packetHandler, PacketReader = packetReader }; m_PacketHandlers.Add(packetHandler.PacketPriority, packetExecuteInfo); }
/// <summary> /// 执行网络消息包指令 /// </summary> public void Execute() { PacketHandler.OnReceive(NetState, PacketReader); }