Exemplo n.º 1
0
        public LLPacketQueue(UUID agentId, ClientStackUserSettings userSettings)
        {
            // While working on this, the BlockingQueue had me fooled for a bit.
            // The Blocking queue causes the thread to stop until there's something
            // in it to process.  it's an on-purpose threadlock though because
            // without it, the clientloop will suck up all sim resources.

            SendQueue = new OpenSim.Framework.BlockingQueue<LLQueItem>();

            IncomingPacketQueue = new Queue<LLQueItem>();
            OutgoingPacketQueue = new Queue<LLQueItem>();
            ResendOutgoingPacketQueue = new Queue<LLQueItem>();
            LandOutgoingPacketQueue = new Queue<LLQueItem>();
            WindOutgoingPacketQueue = new Queue<LLQueItem>();
            CloudOutgoingPacketQueue = new Queue<LLQueItem>();
            TaskOutgoingPacketQueue = new Queue<LLQueItem>();
            TaskLowpriorityPacketQueue = new Queue<LLQueItem>();
            TextureOutgoingPacketQueue = new Queue<LLQueItem>();
            AssetOutgoingPacketQueue = new Queue<LLQueItem>();

            // Store the throttle multiplier for posterity.
            throttleMultiplier = userSettings.ClientThrottleMultipler;

            // Set up the throttle classes (min, max, current) in bits per second
            ResendThrottle =    new LLPacketThrottle(5000, 100000, 16000, userSettings.ClientThrottleMultipler);
            LandThrottle =      new LLPacketThrottle(1000, 100000, 2000, userSettings.ClientThrottleMultipler);
            WindThrottle =      new LLPacketThrottle(0, 100000, 0, userSettings.ClientThrottleMultipler);
            CloudThrottle =     new LLPacketThrottle(0, 100000, 0, userSettings.ClientThrottleMultipler);
            TaskThrottle =      new LLPacketThrottle(1000, 800000, 3000, userSettings.ClientThrottleMultipler);
            AssetThrottle =     new LLPacketThrottle(1000, 800000, 1000, userSettings.ClientThrottleMultipler);
            TextureThrottle =   new LLPacketThrottle(1000, 800000, 4000, userSettings.ClientThrottleMultipler);
            
            // Total Throttle trumps all - it is the number of bits in total that are allowed to go out per second.            
            ThrottleSettings totalThrottleSettings = userSettings.TotalThrottleSettings;
            if (null == totalThrottleSettings)
            {                
                totalThrottleSettings = new ThrottleSettings(0, 1500000, 28000);
            }
            
            TotalThrottle 
                = new LLPacketThrottle(
                    totalThrottleSettings.Min, totalThrottleSettings.Max, totalThrottleSettings.Current,
                    userSettings.ClientThrottleMultipler);

            throttleTimer = new Timer((int) (throttletimems/throttleTimeDivisor));
            throttleTimer.Elapsed += ThrottleTimerElapsed;
            throttleTimer.Start();

            // TIMERS needed for this
            // LastThrottle = DateTime.Now.Ticks;
            // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor);

            m_agentId = agentId;

            if (StatsManager.SimExtraStats != null)
            {
                StatsManager.SimExtraStats.RegisterPacketQueueStatsProvider(m_agentId, this);
            }
        }
Exemplo n.º 2
0
        public void OnMouseMoving(object sender, MouseEventArgs e)
        {
            if (_destroyed)
            {
                return;
            }


            // TODO: REVIEW THIS
            // Per MSDN:
            // if the system runs continuously, TickCount will increment from zero to Int32.MaxValue for approximately 24.9 days,
            // then jump to Int32.MinValue, which is a negative number, then increment back to zero during the next 24.9 days.
            long elapsed = Environment.TickCount - _lastMouseMoveMessageTick;

            lock (_mouseEventLock)
            {
                _lastMouseMoveTick = Environment.TickCount;

                try
                {
                    CurrentMousePosition = e.GetPosition(TileImage);
                }
                catch (ArgumentException)
                {
                    return; // Happens sometimes on layout changes
                }

                bool okToSend = false;

                ThrottleSettings   settings = ThrottleSettings.Default;
                PerformanceMonitor p        = PerformanceMonitor.CurrentInstance;


                // TODO: Should maxPendingAllowed be adjusted based on FPS? Image Size? and the current operation?
                // Experiment shows that 2 provides the smoothest experience for pan, zoom, w/l and 4 is best for stacking (in office).
                // For big images (1x1 layout), pan and zoom work best when maxPendingAllowed=1.
                int maxPendingAllowed = settings.MaxPendingMouseMoveMsgAllowed;

                if (!ServerEntity.HasCapture)
                {
                    if (IsSelected)
                    {
                        // Although we are not tracking the mouse movement,
                        // we still send mouse position to the server to obtain the new image
                        // when the mouse is hovering over the tools.
                        if (_timer == null)
                        {
                            //TODO (CR May 2010): should we just start handling the mouse globally through the helper?  It might simplify the code.
                            //_lastMouseMoveMessageTick = Environment.TickCount;
                            //SendMouseMoveMessage();
                            StartMouseMoveTimer();
                        }
                        else
                        {
                            switch (settings.Strategy)
                            {
                            case ThrottleStrategy.WhenMouseMoveRspReceived:
                                okToSend = elapsed >=
                                           p.AverageMouseMoveMsgRTTWithResponse /
                                           settings.MaxPendingMouseMoveMsgAllowed && p.SendLag < maxPendingAllowed &&
                                           p.RenderingLag < 5;
                                break;
                            }


                            if (okToSend)
                            {
                                // TODO: REVIEW THIS
                                // Per MSDN:
                                // if the system runs continuously, TickCount will increment from zero to Int32.MaxValue for approximately 24.9 days,
                                // then jump to Int32.MinValue, which is a negative number, then increment back to zero during the next 24.9 days.
                                _lastMouseMoveMessageTick = Environment.TickCount;
                                SendMouseMoveMessage();
                            }
                        }
                    }
                    return;
                }

                switch (settings.Strategy)
                {
                case ThrottleStrategy.WhenMouseMoveRspReceived:
                    okToSend = elapsed >=
                               p.AverageMouseMoveMsgRTTWithResponse / settings.MaxPendingMouseMoveMsgAllowed &&
                               p.SendLag < maxPendingAllowed && p.RenderingLag < 5;
                    break;
                }

                if (okToSend)
                {
                    _lastMouseMoveMessageTick = Environment.TickCount;
                    SendMouseMoveMessage();
                }
            }
        }