예제 #1
0
        public bool AcceptOffer(Offer offer)
        {
            OfferAccepted?.Invoke(this, offer);

            var tradeOffer = new TradeOffer.TradeOffer(session, offer);
            var accepted   = tradeOffer.Accept();

            return(accepted.Accepted);
        }
예제 #2
0
        private void CheckForSentOfferChanges(List <Offer> offers)
        {
            if (offers != null)
            {
                var newOffers = offers.Where(o => o.TradeOfferState == TradeOfferState.TradeOfferStateActive || o.TradeOfferState == TradeOfferState.TradeOfferStateAccepted);

                foreach (var aOffer in newOffers)
                {
                    var wasRaised = false;
                    foreach (var oldsOffer in LastSentOffersData)
                    {
                        if (aOffer.TradeOfferId == oldsOffer.TradeOfferId)
                        {
                            if (oldsOffer.TradeOfferState == TradeOfferState.TradeOfferStateAccepted)
                            {
                                wasRaised = true;
                            }
                        }
                        if (!wasRaised)
                        {
                            //AcceptOffer(aOffer);
                            OfferAccepted?.Invoke(this, aOffer);
                        }
                    }
                }

                var declined = offers.Where(o => o.TradeOfferState == TradeOfferState.TradeOfferStateDeclined);

                foreach (var aOffer in declined)
                {
                    var wasRaised = false;
                    foreach (var oldsOffer in LastSentOffersData)
                    {
                        if (aOffer.TradeOfferId == oldsOffer.TradeOfferId)
                        {
                            if (oldsOffer.TradeOfferState == TradeOfferState.TradeOfferStateDeclined)
                            {
                                wasRaised = true;
                            }
                        }
                        if (!wasRaised)
                        {
                            OfferDeclined?.Invoke(this, aOffer);
                        }
                    }
                }

                LastSentOffersData = new List <Offer>(offers);
            }
        }
예제 #3
0
 private void CheckForReceivedOfferChanges(List <Offer> offers)
 {
     foreach (var newOffer in offers)
     {
         var isOld = false;
         foreach (var oldsOffer in LastReceivedOffersData)
         {
             if (newOffer.TradeOfferId == oldsOffer.TradeOfferId)
             {
                 isOld = true;
                 break;
             }
         }
         if (!isOld)
         {
             NewOffer?.Invoke(this, newOffer);
             //AcceptOffer(newOffer);
             OfferAccepted?.Invoke(this, newOffer);
         }
     }
     LastReceivedOffersData = new List <Offer>(offers);
 }