当前位置: 首页>>代码示例>>C#>>正文


C# OutgoingPacket.DecRef方法代码示例

本文整理汇总了C#中OpenSim.Region.ClientStack.LindenUDP.OutgoingPacket.DecRef方法的典型用法代码示例。如果您正苦于以下问题:C# OutgoingPacket.DecRef方法的具体用法?C# OutgoingPacket.DecRef怎么用?C# OutgoingPacket.DecRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenSim.Region.ClientStack.LindenUDP.OutgoingPacket的用法示例。


在下文中一共展示了OutgoingPacket.DecRef方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EnqueueOutgoing

        public bool EnqueueOutgoing(OutgoingPacket packet)
        {
            int category = (int)packet.Category;

            if (category >= 0 && category < m_packetOutboxes.Length)
            {
                OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category];

                // Not enough tokens in the bucket, queue this packet

                //check the queue
                //Dont drop resends this can mess up the buffer pool as well as make the connection situation much worse
                if (_currentOutboundQueueSize > MAX_TOTAL_QUEUE_SIZE && (packet.Buffer[0] & Helpers.MSG_RESENT) == 0)
                {
                    //queue already has too much data in it..
                    //can we drop this packet?
                    byte flags = packet.Buffer[0];
                    bool isReliable = (flags & Helpers.MSG_RELIABLE) != 0;

                    if (!isReliable 
                        && packet.Type != PacketType.PacketAck
                        && packet.Type != PacketType.CompletePingCheck)
                    {
                        //packet is unreliable and will be dropped
                        this.TestReportPacketDrop(packet);
                        packet.DecRef(m_udpServer.ByteBufferPool);
                    }
                    else
                    {
                        if (_currentOutboundQueueSize < MAX_TOTAL_QUEUE_SIZE * 1.5)
                        {
                            this.TestReportPacketShouldDrop(packet);
                            Interlocked.Add(ref _currentOutboundQueueSize, packet.DataSize);
                            packet.AddRef();
                            queue.Enqueue(packet);
                        }
                        else
                        {
                            //this connection is in a pretty critical state and probably will never catch up.
                            //drop all packets until we start to catch up. This includes acks which will disconnect
                            //the client eventually anyways

                            this.TestReportCriticalPacketDrop(packet);
                            packet.DecRef(m_udpServer.ByteBufferPool);
                        }
                    }
                }
                else
                {
                    Interlocked.Add(ref _currentOutboundQueueSize, packet.DataSize);

                    packet.AddRef();
                    queue.Enqueue(packet);
                }

                return true;
            }
            else
            {
                // We don't have a token bucket for this category, so it will not be queued
                return false;
            }
        }
开发者ID:kf6kjg,项目名称:halcyon,代码行数:63,代码来源:LLUDPClient.cs

示例2: SendCompleted

 protected override void SendCompleted(OutgoingPacket packet)
 {
     packet.DecRef(_bufferPool);
 }
开发者ID:digitalmystic,项目名称:halcyon,代码行数:4,代码来源:LLUDPServer.cs


注:本文中的OpenSim.Region.ClientStack.LindenUDP.OutgoingPacket.DecRef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。