예제 #1
0
        private void OnServerEventReceived(object sender, ServerEventReceivedEventArgs eventSet)
        {
            Platform.Log(LogLevel.Debug, "==> {0}: IN MSG # {1}", Environment.TickCount, eventSet.EventSet.Number);

            if (ThrottleSettings.Default.LagDetectionStrategy == LagDetectionStrategy.WhenMouseMoveIsProcessed)
            {
                PerformanceMonitor.CurrentInstance.DecrementSendLag(eventSet.EventSet.Events.Count(i => i is MouseMoveProcessedEvent));
            }

            int tileUpdateEvCount = eventSet.EventSet.Events.Count(i => i is TileUpdatedEvent);

            if (tileUpdateEvCount > 0)
            {
                //if (ThrottleSettings.Default.LagDetectionStrategy == LagDetectionStrategy.WhenTileUpdateReturn)
                //    PerformanceMonitor.CurrentInstance.DecrementSendLag(eventSet.Events.Count((i) => i is TileUpdatedEvent));

                PerformanceMonitor.CurrentInstance.RenderingLag += tileUpdateEvCount;
                if (tileUpdateEvCount > 1)
                {
                    Platform.Log(LogLevel.Debug, "########## {0} tile update events received ###########", tileUpdateEvCount);
                }
            }


            lock (_incomingEventSync)
            {
                _incomingEventSets[eventSet.EventSet.Number] = eventSet.EventSet;
                Monitor.Pulse(_incomingEventSync);
            }
        }
예제 #2
0
        private void MessageSent(object sender, ProcessMessagesCompletedEventArgs e)
        {
            // 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.
            ApplicationActivityMonitor.Instance.LastActivityTick = Environment.TickCount;
            var msgs = e.UserState as MessageSet;

            if (msgs != null)
            {
                PerformanceMonitor.CurrentInstance.DecrementMouseWheelMsgCount(msgs.Messages.Count(i => i is MouseWheelMessage));
            }

            if (e.Error != null)
            {
                OnError(e.Error);
                return;
            }

            if (e.Result != null)
            {
                if (e.Result.EventSet != null && e.Result.EventSet.Events != null)
                {
                    bool isMoveMoveMsg = msgs != null && msgs.Messages.Any(i => i is MouseMoveMessage);
                    if (isMoveMoveMsg)
                    {
                        long dt = Environment.TickCount - msgs.Tick;
                        var  p  = PerformanceMonitor.CurrentInstance;

                        //bool tileUpdateEventReturned = e.Result.EventSet != null && e.Result.EventSet.Events.Any((i) => i is TileUpdatedEvent);

                        p.LogMouseMoveRTTWithResponse(msgs.Number, dt);
                    }

                    if (e.Result.EventSet != null)
                    {
                        if (!_connectionOpened)
                        {
                            Platform.Log(LogLevel.Error, "Received messages after connection has been closed!");
                        }
                        else if (MessageReceived != null)
                        {
                            var args = new ServerEventReceivedEventArgs
                            {
                                EventSet = e.Result.EventSet
                            };
                            MessageReceived(this, args);
                        }
                        else
                        {
                            Platform.Log(LogLevel.Error, "Received messages without message event registered!");
                        }
                    }
                }
            }
        }
예제 #3
0
        private void MessageSent(object sender, ProcessMessagesCompletedEventArgs e)
        {
            // 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.
            ApplicationActivityMonitor.Instance.LastActivityTick = Environment.TickCount;
            var msgs = e.UserState as MessageSet;
            if (msgs!=null)
                PerformanceMonitor.CurrentInstance.DecrementMouseWheelMsgCount(msgs.Messages.Count(i => i is MouseWheelMessage));

            if (e.Error != null)
            {
                OnError(e.Error);
                return;
            }

            if (e.Result != null)
            {
                if (e.Result.EventSet != null && e.Result.EventSet.Events != null)
                {
                    bool isMoveMoveMsg = msgs != null && msgs.Messages.Any(i => i is MouseMoveMessage);
                    if (isMoveMoveMsg)
                    {

                        long dt = Environment.TickCount - msgs.Tick;
                        var p = PerformanceMonitor.CurrentInstance;

                        //bool tileUpdateEventReturned = e.Result.EventSet != null && e.Result.EventSet.Events.Any((i) => i is TileUpdatedEvent);

                        p.LogMouseMoveRTTWithResponse(msgs.Number, dt);
                    }

                    if (e.Result.EventSet != null)
                    {
                        if (!_connectionOpened)
                        {
                            Platform.Log(LogLevel.Error, "Received messages after connection has been closed!");
                        }
                        else if (MessageReceived != null)
                        {
                            var args = new ServerEventReceivedEventArgs
                                           {
                                               EventSet = e.Result.EventSet
                                           };
                            MessageReceived(this, args);
                        }
                        else
                        {
                            Platform.Log(LogLevel.Error, "Received messages without message event registered!");
                        }
                    }
                }
            }
        }
예제 #4
0
        private void OnServerEventReceived(object sender, ServerEventReceivedEventArgs eventSet)
        {
            Platform.Log(LogLevel.Debug, "==> {0}: IN MSG # {1}", Environment.TickCount, eventSet.EventSet.Number);

            if (ThrottleSettings.Default.LagDetectionStrategy == LagDetectionStrategy.WhenMouseMoveIsProcessed)
                PerformanceMonitor.CurrentInstance.DecrementSendLag(eventSet.EventSet.Events.Count(i => i is MouseMoveProcessedEvent));

            int tileUpdateEvCount = eventSet.EventSet.Events.Count(i => i is TileUpdatedEvent);
            if (tileUpdateEvCount > 0)
            {
                //if (ThrottleSettings.Default.LagDetectionStrategy == LagDetectionStrategy.WhenTileUpdateReturn)
                //    PerformanceMonitor.CurrentInstance.DecrementSendLag(eventSet.Events.Count((i) => i is TileUpdatedEvent));

                PerformanceMonitor.CurrentInstance.RenderingLag += tileUpdateEvCount;
                if (tileUpdateEvCount > 1)
                    Platform.Log(LogLevel.Debug, "########## {0} tile update events received ###########", tileUpdateEvCount);
            }


            lock (_incomingEventSync)
            {
                _incomingEventSets[eventSet.EventSet.Number] = eventSet.EventSet;
                Monitor.Pulse(_incomingEventSync);
            }
        }