예제 #1
0
        /// <summary>
        /// 压入数据包至优先级处理列表
        /// </summary>
        public void Enqueue(PacketHandler packetHandler, PacketReader packetReader)
        {
            PacketExecuteInfo packetExecuteInfo = new PacketExecuteInfo {
                PacketHandler = packetHandler, PacketReader = packetReader
            };

            m_PacketHandlers.Add(packetHandler.PacketPriority, packetExecuteInfo);
        }
예제 #2
0
        /// <summary>
        /// 获取优先级最高的数据包
        /// </summary>
        /// <returns></returns>
        public PacketExecuteInfo DequeueFirstPriority()
        {
            IEnumerable <PacketExecuteInfo> outValues = null;

            // 获取优先级最高的
            m_PacketHandlers.TryEnumerateValuesForKey(PacketPriority.Highest, out outValues);
            if (outValues != null)
            {
                PacketExecuteInfo packetExecuteInfo = outValues.FirstOrDefault <PacketExecuteInfo>();
                if (packetExecuteInfo != null)
                {
                    m_PacketHandlers.Remove(PacketPriority.Highest, packetExecuteInfo);

                    return(packetExecuteInfo);
                }
            }

            // 获取优先级通常之上的
            outValues = null;
            m_PacketHandlers.TryEnumerateValuesForKey(PacketPriority.BelowNormal, out outValues);
            if (outValues != null)
            {
                PacketExecuteInfo packetExecuteInfo = outValues.FirstOrDefault <PacketExecuteInfo>();
                if (packetExecuteInfo != null)
                {
                    m_PacketHandlers.Remove(PacketPriority.BelowNormal, packetExecuteInfo);

                    return(packetExecuteInfo);
                }
            }

            // 获取优先级通常的
            outValues = null;
            m_PacketHandlers.TryEnumerateValuesForKey(PacketPriority.Normal, out outValues);
            if (outValues != null)
            {
                PacketExecuteInfo packetExecuteInfo = outValues.FirstOrDefault <PacketExecuteInfo>();
                if (packetExecuteInfo != null)
                {
                    m_PacketHandlers.Remove(PacketPriority.Normal, packetExecuteInfo);

                    return(packetExecuteInfo);
                }
            }

            // 获取优先级通常之下的
            outValues = null;
            m_PacketHandlers.TryEnumerateValuesForKey(PacketPriority.AboveNormal, out outValues);
            if (outValues != null)
            {
                PacketExecuteInfo packetExecuteInfo = outValues.FirstOrDefault <PacketExecuteInfo>();
                if (packetExecuteInfo != null)
                {
                    m_PacketHandlers.Remove(PacketPriority.AboveNormal, packetExecuteInfo);

                    return(packetExecuteInfo);
                }
            }

            // 获取优先级最低的
            outValues = null;
            m_PacketHandlers.TryEnumerateValuesForKey(PacketPriority.Lowest, out outValues);
            if (outValues != null)
            {
                PacketExecuteInfo packetExecuteInfo = outValues.FirstOrDefault <PacketExecuteInfo>();
                if (packetExecuteInfo != null)
                {
                    m_PacketHandlers.Remove(PacketPriority.Lowest, packetExecuteInfo);

                    return(packetExecuteInfo);
                }
            }

            return(null);
        }
예제 #3
0
        /// <summary>
        /// 压入数据包至优先级处理列表
        /// </summary>
        public void Enqueue(PacketHandler packetHandler, PacketReader packetReader)
        {
            PacketExecuteInfo packetExecuteInfo = new PacketExecuteInfo { PacketHandler = packetHandler, PacketReader = packetReader };

            m_PacketHandlers.Add(packetHandler.PacketPriority, packetExecuteInfo);
        }