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


C# OutgoingPacket.AddRef方法代码示例

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


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

示例1: AsyncBeginSend

        public void AsyncBeginSend(OutgoingPacket packet)
        {
            if (!m_shutdownFlag)
            {
                try
                {
                    packet.AddRef();

                    m_udpSocket.BeginSendTo(
                        packet.Buffer.Data,
                        0,
                        packet.DataSize,
                        SocketFlags.None,
                        packet.Destination,
                        AsyncEndSend,
                        packet);
                }
                catch (SocketException) { }
                catch (ObjectDisposedException) { }
            }
        }
开发者ID:emperorstarfinder,项目名称:halcyon,代码行数:21,代码来源:OpenSimUDPBase.cs

示例2: 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

示例3: Add

 /// <summary>
 /// Add an unacked packet to the collection
 /// </summary>
 /// <param name="packet">Packet that is awaiting acknowledgement</param>
 /// <returns>True if the packet was successfully added, false if the
 /// packet already existed in the collection</returns>
 /// <remarks>This does not immediately add the ACK to the collection,
 /// it only queues it so it can be added in a thread-safe way later</remarks>
 public void Add(OutgoingPacket packet)
 {
     packet.AddRef();
     m_pendingAdds.Enqueue(packet);
 }
开发者ID:kf6kjg,项目名称:halcyon,代码行数:13,代码来源:UnackedPacketCollection.cs


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