Exemplo n.º 1
0
        /// <summary>
        /// Reads a <see cref="PeerTradeInfoServerMessage.Canceled"/>.
        /// </summary>
        /// <param name="reader">The <see cref="BitStream"/> containing the data to read.</param>
        void ReadCanceled(BitStream reader)
        {
            Debug.Assert(IsTradeOpen, "Why is the trade table not open...?");

            var sourceCanceled = reader.ReadBool();

            // Raise events
            OnTradeCanceled(sourceCanceled);
            if (TradeCanceled != null)
            {
                TradeCanceled.Raise(this, new ClientPeerTradeInfoHandlerTradeCanceledEventArgs(sourceCanceled));
            }
        }
Exemplo n.º 2
0
        private void ReadLogsInBack()
        {
            if (isReading)
            {
                return;
            }
            isReading = true;
            using (FileStream fs = new FileStream(PoE_Logs_File, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                using (var sr = new StreamReader(fs))
                {
                    int    li = 0;
                    string ll = string.Empty;
                    while (!sr.EndOfStream)
                    {
                        li++;
                        ll = sr.ReadLine();

                        if (not_first && li > last_index)
                        {
                            if (ll.Contains($"{Properties.Settings.Default.PreppendInfoClient} [INFO Client"))
                            {
                                _LoggerService.Log(ll);
                                if (ll.Contains("AFK mode is now ON"))
                                {
                                    AFK.Invoke(this, new EventArgs());
                                }
                                else if (ll.Contains("has left the area"))
                                {
                                    CustomerLeft.Invoke(this, new TradeArgs {
                                        CustomerName = GetCustomerNick(ll)
                                    });
                                }
                                else if (ll.Contains("has joined the area"))
                                {
                                    CustomerArrived.Invoke(this, new TradeArgs {
                                        CustomerName = GetCustomerNick(ll)
                                    });
                                }
                                else if (ll.Contains("Trade accepted"))
                                {
                                    TradeAccepted.Invoke(this, new TradeArgs {
                                    });
                                }
                                else if (ll.Contains("Trade cancel"))
                                {
                                    TradeCanceled.Invoke(this, new TradeArgs {
                                    });
                                }
                                else if (ll.Contains("@"))
                                {
                                    var customer = GetInfo(ll);
                                    if (customer != null)
                                    {
                                        TradeRequest.Invoke(this, new TradeArgs {
                                            customer = customer
                                        });
                                    }
                                }
                            }
                        }
                    }

                    if (li > last_index)
                    {
                        last_index = li;
                        if (!not_first)
                        {
                            not_first = true;
                        }
                    }
                    isReading = false;
                }
            }
        }