當前位置: 首頁>>代碼示例>>C#>>正文


C# LLUDPClient.BackoffRTO方法代碼示例

本文整理匯總了C#中OpenSim.Region.ClientStack.LindenUDP.LLUDPClient.BackoffRTO方法的典型用法代碼示例。如果您正苦於以下問題:C# LLUDPClient.BackoffRTO方法的具體用法?C# LLUDPClient.BackoffRTO怎麽用?C# LLUDPClient.BackoffRTO使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenSim.Region.ClientStack.LindenUDP.LLUDPClient的用法示例。


在下文中一共展示了LLUDPClient.BackoffRTO方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ResendUnacked

        public void ResendUnacked(LLUDPClient udpClient)
        {
            if (!udpClient.IsConnected)
                return;

            // Disconnect an agent if no packets are received for some time
            if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * ClientTimeOut && !udpClient.IsPaused)
            {
                m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);

                ILoginMonitor monitor = (ILoginMonitor)m_scene.RequestModuleInterface<IMonitorModule>().GetMonitor("", MonitorModuleHelper.LoginMonitor);
                if (monitor != null)
                {
                    monitor.AddAbnormalClientThreadTermination();
                }
                RemoveClient(udpClient);
                return;
            }

            // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO
            List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO);

            if (expiredPackets != null)
            {
                //m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO);

                // Exponential backoff of the retransmission timeout
                udpClient.BackoffRTO();

                for (int i = 0; i < expiredPackets.Count; ++i)
                {
                    if (expiredPackets[i].UnackedMethod != null)
                        expiredPackets[i].UnackedMethod(expiredPackets[i]);
                }

                // Resend packets
                for (int i = 0; i < expiredPackets.Count; i++)
                {
                    if (expiredPackets[i].UnackedMethod != null)
                        continue; //If its not null, it has taken care of the packet sending on its own

                    OutgoingPacket outgoingPacket = expiredPackets[i];

                    //m_log.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed",
                    //    outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount);

                    // Set the resent flag
                    outgoingPacket.Buffer.Data[0] = (byte)(outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT);

                    // resend in its original category
                    outgoingPacket.Category = ThrottleOutPacketType.Resend;

                    // Bump up the resend count on this packet
                    Interlocked.Increment(ref outgoingPacket.ResendCount);
                    //Interlocked.Increment(ref Stats.ResentPackets);

                    // Requeue or resend the packet
                    if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket))
                        SendPacketFinal(outgoingPacket);
                }
            }
        }
開發者ID:HGExchange,項目名稱:Aurora-Sim,代碼行數:62,代碼來源:LLUDPServer.cs

示例2: ResendUnacked

        public void ResendUnacked(LLUDPClient udpClient)
        {
            if (!udpClient.IsConnected)
                return;

            // Disconnect an agent if no packets are received for some time
            if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * ClientTimeOut && !udpClient.IsPaused)
            {
                m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);

                if (m_scene.Stats is OpenSim.Framework.Statistics.SimExtraStatsCollector)
                {
                    OpenSim.Framework.Statistics.SimExtraStatsCollector stats = m_scene.Stats as OpenSim.Framework.Statistics.SimExtraStatsCollector;
                    stats.AddAbnormalClientThreadTermination();
                }
                RemoveClient(udpClient);
                return;
            }

            // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO
            List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO);

            if (expiredPackets != null)
            {
                //m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO);

                // Exponential backoff of the retransmission timeout
                udpClient.BackoffRTO();

                // Resend packets
                for (int i = 0; i < expiredPackets.Count; i++)
                {
                    OutgoingPacket outgoingPacket = expiredPackets[i];

                    //m_log.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed",
                    //    outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount);

                    // Set the resent flag
                    outgoingPacket.Buffer.Data[0] = (byte)(outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT);
                    outgoingPacket.Category = ThrottleOutPacketType.Resend;

                    // Bump up the resend count on this packet
                    Interlocked.Increment(ref outgoingPacket.ResendCount);
                    //Interlocked.Increment(ref Stats.ResentPackets);

                    // Requeue or resend the packet
                    if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket))
                        SendPacketFinal(outgoingPacket);
                }
            }
        }
開發者ID:WordfromtheWise,項目名稱:Aurora,代碼行數:51,代碼來源:LLUDPServer.cs

示例3: ResendUnacked

        public void ResendUnacked(LLUDPClient udpClient)
        {
            if (!udpClient.IsConnected)
                return;

            // Disconnect an agent if no packets are received for some time
            //FIXME: Make 60 an .ini setting
            if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * 60)
            {
                IClientAPI client;
                if (m_scene.TryGetClient(udpClient.AgentID, out client))
                {
                    if (client.IsActive)   // to prevent duplicate reporting
                        m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);

                    RemoveClient(client);
                }
                return;
            }

            // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO
            KeyValuePair<UnackedPacketCollection.ResendReason, List<OutgoingPacket>> expiredPackets 
                = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO);

            if (expiredPackets.Key != UnackedPacketCollection.ResendReason.None)
            {
                //m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO);

                // Exponential backoff of the retransmission timeout
                if ((expiredPackets.Key & UnackedPacketCollection.ResendReason.TimeoutExpired) != 0) udpClient.BackoffRTO();

                var packetList = expiredPackets.Value;

                // Resend packets
                for (int i = 0; i < packetList.Count; i++)
                {
                    OutgoingPacket outgoingPacket = packetList[i];

                    /*m_log.DebugFormat("[LLUDPSERVER]: {0} Resending packet #{1} (attempt {2}), {3}ms have passed",
                        (expiredPackets.Key & UnackedPacketCollection.ResendReason.FastRetransmit) != 0 ? "(Fast)" : "",
                        outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount);
                    */

                    // Set the resent flag
                    outgoingPacket.Buffer[0] = (byte)(outgoingPacket.Buffer[0] | Helpers.MSG_RESENT);
                    outgoingPacket.Category = (int) ThrottleOutPacketType.Resend;

                    // Bump up the resend count on this packet
                    Interlocked.Increment(ref outgoingPacket.ResendCount);
                    //Interlocked.Increment(ref Stats.ResentPackets);

                    // Requeue or resend the packet
                    if (!udpClient.EnqueueOutgoing(outgoingPacket))
                        SendPacketFinal(outgoingPacket);
                }

                /*
                if (packetList.Count != 0)
                {
                    m_log.DebugFormat("[LLUDPSERVER]: {0} Resent {1} packet(s) for {2}",
                        (expiredPackets.Key & UnackedPacketCollection.ResendReason.FastRetransmit) != 0 ? "(Fast)" : "",
                        packetList.Count, udpClient.AgentID);
                }*/
            }
        }
開發者ID:digitalmystic,項目名稱:halcyon,代碼行數:65,代碼來源:LLUDPServer.cs

示例4: HandleUnacked

        public void HandleUnacked(LLUDPClient udpClient)
        {
            if (!udpClient.IsConnected)
                return;

            // Disconnect an agent if no packets are received for some time
            //FIXME: Make 60 an .ini setting
            if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * 60)
            {
                m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);
                StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();

                RemoveClient(udpClient);
                return;
            }

            // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO
            List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO);

            if (expiredPackets != null)
            {
                //m_log.Debug("[LLUDPSERVER]: Handling " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO);
                // Exponential backoff of the retransmission timeout
                udpClient.BackoffRTO();
                for (int i = 0; i < expiredPackets.Count; ++i)
                    expiredPackets[i].UnackedMethod(expiredPackets[i]);
            }
        }
開發者ID:OpenPlex-Sim,項目名稱:opensim,代碼行數:28,代碼來源:LLUDPServer.cs

示例5: ResendUnacked

        public void ResendUnacked(LLUDPClient udpClient)
        {
            if (!udpClient.IsConnected)
                return;

            // Disconnect an agent if no packets are received for some time
            if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000*ClientTimeOut &&
                !udpClient.IsPaused)
            {
                MainConsole.Instance.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);

                ILoginMonitor monitor =
                    (ILoginMonitor)
                    m_scene.RequestModuleInterface<IMonitorModule>().GetMonitor("", MonitorModuleHelper.LoginMonitor);
                if (monitor != null)
                    monitor.AddAbnormalClientThreadTermination();

                RemoveClient(udpClient);
                return;
            }

            // Get a list of all of the packets that have been sitting unacked longer than udpClient.RTO
            List<OutgoingPacket> expiredPackets = udpClient.NeedAcks.GetExpiredPackets(udpClient.RTO);

            if (expiredPackets != null)
            {
                //uncomment one line below for added debuging -VS
                MainConsole.Instance.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO);

                // Exponential backoff of the retransmission timeout
                udpClient.BackoffRTO();

#if (!ISWIN)
                foreach (OutgoingPacket t in expiredPackets)
                {
                    if (t.UnackedMethod != null)
                    {
                        t.UnackedMethod(t);
                    }
                }
#else
                foreach (OutgoingPacket t in expiredPackets.Where(t => t.UnackedMethod != null))
                {
                    t.UnackedMethod(t);
                }
#endif

                // Resend packets
#if (!ISWIN)
                foreach (OutgoingPacket outgoingPacket in expiredPackets)
                {
                    if (outgoingPacket.UnackedMethod == null)
                    {
                        //MainConsole.Instance.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed",
                        //    outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount);

                        // Set the resent flag
                        outgoingPacket.Buffer.Data[0] = (byte) (outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT);

                        // resend in its original category
                        outgoingPacket.Category = ThrottleOutPacketType.Resend;

                        // Bump up the resend count on this packet
                        Interlocked.Increment(ref outgoingPacket.ResendCount);
                        //Interlocked.Increment(ref Stats.ResentPackets);

                        // Requeue or resend the packet
                        if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket))
                            SendPacketFinal(outgoingPacket);
                    }
                }
#else
                foreach (OutgoingPacket outgoingPacket in expiredPackets.Where(t => t.UnackedMethod == null))
                {
                    //MainConsole.Instance.DebugFormat("[LLUDPSERVER]: Resending packet #{0} (attempt {1}), {2}ms have passed",
                    //    outgoingPacket.SequenceNumber, outgoingPacket.ResendCount, Environment.TickCount - outgoingPacket.TickCount);

                    // Set the resent flag
                    outgoingPacket.Buffer.Data[0] = (byte)(outgoingPacket.Buffer.Data[0] | Helpers.MSG_RESENT);

                    // resend in its original category
                    outgoingPacket.Category = ThrottleOutPacketType.Resend;

                    // Bump up the resend count on this packet
                    Interlocked.Increment(ref outgoingPacket.ResendCount);
                    //Interlocked.Increment(ref Stats.ResentPackets);

                    // Requeue or resend the packet
                    if (!outgoingPacket.Client.EnqueueOutgoing(outgoingPacket))
                        SendPacketFinal(outgoingPacket);
                }
#endif
            }
        }
開發者ID:samiam123,項目名稱:Aurora-Sim,代碼行數:94,代碼來源:LLUDPServer.cs


注:本文中的OpenSim.Region.ClientStack.LindenUDP.LLUDPClient.BackoffRTO方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。