コード例 #1
0
        /// <summary>
        /// Called when [file changed].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="FileSystemEventArgs"/> instance containing the event data.</param>
        private void OnFileChanged(string newline)
        {
            if (string.IsNullOrEmpty(newline))
            {
                return;
            }

            // TradeEvent need to be parse before whisper
            var tradeEvent = TradeEvent.TryParse(newline);

            if (tradeEvent != null)
            {
                this.NewOffer?.Invoke(this, tradeEvent);
                return;
            }

            var whisperEvent = WhisperEvent.TryParse(newline);

            if (whisperEvent != null)
            {
                this.Whispered?.Invoke(this, whisperEvent);
                return;
            }

            var locationEvent = LocationChangedEvent.TryParse(newline);

            if (locationEvent != null)
            {
                this.LocationChanged?.Invoke(this, locationEvent);
                return;
            }

            var tradeAcceptedEvent = TradeAcceptedEvent.TryParse(newline);

            if (tradeAcceptedEvent != null)
            {
                this.TradeAccepted?.Invoke(this, tradeAcceptedEvent);
                return;
            }

            var monsterEvent = MonstersRemainEvent.TryParse(newline);

            if (monsterEvent != null)
            {
                this.RemainingMonsters?.Invoke(this, monsterEvent);
                return;
            }

            var playerJoinEvent = PlayerJoinedEvent.TryParse(newline);

            if (playerJoinEvent != null)
            {
                this.PlayerJoined?.Invoke(this, playerJoinEvent);
                return;
            }

            var playerLeftEvent = PlayerLeftEvent.TryParse(newline);

            if (playerLeftEvent != null)
            {
                this.PlayerLeft?.Invoke(this, playerLeftEvent);
                return;
            }

            Logger.Trace($"Not parsed: {newline}");
        }
コード例 #2
0
        /// <summary>
        /// Called when [file changed].
        /// </summary>
        /// <param name="newline">The newline.</param>
        private void OnFileChanged(string newline)
        {
            if (string.IsNullOrEmpty(newline))
            {
                return;
            }

            try
            {
                // TradeEvent need to be parse before whisper
                var tradeEvent = TradeEvent.TryParse(newline);
                if (tradeEvent != null)
                {
                    this.HandleLeague(tradeEvent);
                    this.IncomingOffer?.Invoke(this, tradeEvent);
                    return;
                }

                var outgoingTradeEvent = OutgoingTradeEvent.TryParse(newline);
                if (outgoingTradeEvent != null)
                {
                    this.HandleLeague(outgoingTradeEvent);
                    this.OutgoingOffer?.Invoke(this, outgoingTradeEvent);
                    return;
                }

                var levelUpEvent = PlayerLevelUpEvent.TryParse(newline);
                if (levelUpEvent != null)
                {
                    this.PlayerLevelUp?.Invoke(this, levelUpEvent);
                    return;
                }

                var whisperEvent = WhisperEvent.TryParse(newline);
                if (whisperEvent != null)
                {
                    this.Whispered?.Invoke(this, whisperEvent);
                    return;
                }

                var locationEvent = LocationChangedEvent.TryParse(newline);
                if (locationEvent != null)
                {
                    Models.PoeApplicationContext.Location = locationEvent.Location;
                    this.LocationChanged?.Invoke(this, locationEvent);
                    return;
                }

                var afkEvent = AfkEvent.TryParse(newline);
                if (afkEvent != null)
                {
                    if (Models.PoeApplicationContext.IsAfk != afkEvent.AfkEnable)
                    {
                        Models.PoeApplicationContext.IsAfk = afkEvent.AfkEnable;
                    }

                    this.AfkChanged?.Invoke(this, afkEvent);
                    return;
                }

                var tradeAcceptedEvent = TradeAcceptedEvent.TryParse(newline);
                if (tradeAcceptedEvent != null)
                {
                    this.TradeAccepted?.Invoke(this, tradeAcceptedEvent);
                    return;
                }

                var monsterEvent = MonstersRemainEvent.TryParse(newline);
                if (monsterEvent != null)
                {
                    this.RemainingMonsters?.Invoke(this, monsterEvent);
                    return;
                }

                var playerJoinEvent = PlayerJoinedEvent.TryParse(newline);
                if (playerJoinEvent != null)
                {
                    this.PlayerJoined?.Invoke(this, playerJoinEvent);
                    return;
                }

                var playerLeftEvent = PlayerLeftEvent.TryParse(newline);
                if (playerLeftEvent != null)
                {
                    this.PlayerLeft?.Invoke(this, playerLeftEvent);
                    return;
                }

                Logger.Trace($"Not parsed: {newline}");
            }
            catch (Exception ex)
            {
                var lineError = $"Line in error: {newline}";
                var exception = new Exception(lineError, ex);
                Logger.Error(exception, exception.Message);

#if !DEBUG
                SentrySdk.AddBreadcrumb(message: lineError, level: BreadcrumbLevel.Error);
                SentrySdk.CaptureException(ex);
#endif
            }
        }
コード例 #3
0
        /// <summary>
        /// Called when [file changed].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="FileSystemEventArgs"/> instance containing the event data.</param>
        private void OnFileChanged(string newline)
        {
            if (string.IsNullOrEmpty(newline))
            {
                return;
            }

            try
            {
                // TradeEvent need to be parse before whisper
                var tradeEvent = TradeEvent.TryParse(newline);
                if (tradeEvent != null)
                {
                    this.IncomingOffer?.Invoke(this, tradeEvent);
                    return;
                }

                var outgoingTradeEvent = OutgoingTradeEvent.TryParse(newline);
                if (outgoingTradeEvent != null)
                {
                    this.OutgoingOffer?.Invoke(this, outgoingTradeEvent);
                    return;
                }

                var whisperEvent = WhisperEvent.TryParse(newline);
                if (whisperEvent != null)
                {
                    this.Whispered?.Invoke(this, whisperEvent);
                    return;
                }

                var locationEvent = LocationChangedEvent.TryParse(newline);
                if (locationEvent != null)
                {
                    this.LocationChanged?.Invoke(this, locationEvent);
                    return;
                }

                var tradeAcceptedEvent = TradeAcceptedEvent.TryParse(newline);
                if (tradeAcceptedEvent != null)
                {
                    this.TradeAccepted?.Invoke(this, tradeAcceptedEvent);
                    return;
                }

                var monsterEvent = MonstersRemainEvent.TryParse(newline);
                if (monsterEvent != null)
                {
                    this.RemainingMonsters?.Invoke(this, monsterEvent);
                    return;
                }

                var playerJoinEvent = PlayerJoinedEvent.TryParse(newline);
                if (playerJoinEvent != null)
                {
                    this.PlayerJoined?.Invoke(this, playerJoinEvent);
                    return;
                }

                var playerLeftEvent = PlayerLeftEvent.TryParse(newline);
                if (playerLeftEvent != null)
                {
                    this.PlayerLeft?.Invoke(this, playerLeftEvent);
                    return;
                }

                Logger.Trace($"Not parsed: {newline}");
            }
            catch (Exception ex)
            {
                var exception = new Exception($"Line in error: {newline}", ex);
                Logger.Error(exception, exception.Message);
#if (!DEBUG)
                SentrySdk.CaptureException(exception);
#endif
            }
        }