Beispiel #1
0
        public string GetTradeStatusErrorString(TradeStatusType tradeStatusType)
        {
            switch (tradeStatusType)
            {
            case TradeStatusType.OnGoing:
                return("is still going on");

            case TradeStatusType.CompletedSuccessfully:
                return("completed successfully");

            case TradeStatusType.UnknownStatus:
                return("CLOSED FOR UNKNOWN REASONS - WHAT CAUSES THIS STATUS!?");

            case TradeStatusType.TradeCancelled:
                return("was cancelled " + (tradeCancelledByBot ? "by bot" : "by other user"));

            case TradeStatusType.SessionExpired:
                return(String.Format("expired because {0} timed out", (otherUserTimingOut ? "other user" : "bot")));

            case TradeStatusType.TradeFailed:
                return("failed unexpectedly");

            default:
                return("STATUS IS UNKNOWN - THIS SHOULD NEVER HAPPEN!");
            }
        }
Beispiel #2
0
        public string GetTradeStatusErrorString(TradeStatusType tradeStatusType)
        {
            switch (tradeStatusType)
            {
            case TradeStatusType.OnGoing:
                return("is still going on");

            case TradeStatusType.CompletedSuccessfully:
                return("completed successfully");

            case TradeStatusType.Empty:
                return("completed empty - no items were exchanged");

            case TradeStatusType.TradeCancelled:
                return("was cancelled " + (tradeCancelledByBot ? "by bot" : "by other user"));

            case TradeStatusType.SessionExpired:
                return(String.Format("expired because {0} timed out", (otherUserTimingOut ? "other user" : "bot")));

            case TradeStatusType.TradeFailed:
                return("failed unexpectedly");

            case TradeStatusType.PendingConfirmation:
                return("completed - pending confirmation");

            default:
                return("STATUS IS UNKNOWN - THIS SHOULD NEVER HAPPEN!");
            }
        }
Beispiel #3
0
        internal void FireOnStatusErrorEvent(TradeStatusType statusType)
        {
            var onStatusErrorEvent = OnStatusError;

            if (onStatusErrorEvent != null)
            {
                onStatusErrorEvent(statusType);
            }
        }
Beispiel #4
0
        /// <summary>
        /// This updates the trade.  This is called at an interval of a
        /// default of 800ms, not including the execution time of the
        /// method itself.
        /// </summary>
        /// <returns><c>true</c> if the other trade partner performed an action; otherwise <c>false</c>.</returns>
        public bool Poll()
        {
            if (!TradeStarted)
            {
                TradeStarted = true;

                // since there is no feedback to let us know that the trade
                // is fully initialized we assume that it is when we start polling.
                if (OnAfterInit != null)
                {
                    OnAfterInit();
                }
            }

            TradeStatus status = RetryWebRequest(session.GetStatus);

            if (status == null)
            {
                return(false);
            }

            TradeStatusType tradeStatusType = (TradeStatusType)status.trade_status;

            switch (tradeStatusType)
            {
            // Nothing happened. i.e. trade hasn't closed yet.
            case TradeStatusType.OnGoing:
                return(HandleTradeOngoing(status));

            // Successful trade
            case TradeStatusType.CompletedSuccessfully:
                HasTradeCompletedOk = true;
                return(false);

            // Email/mobile confirmation
            case TradeStatusType.PendingConfirmation:
                IsTradeAwaitingConfirmation = true;
                tradeOfferID = long.Parse(status.tradeid);
                return(false);

            //On a status of 2, the Steam web code attempts the request two more times
            case TradeStatusType.Empty:
                numUnknownStatusUpdates++;
                if (numUnknownStatusUpdates < 3)
                {
                    return(false);
                }
                break;
            }

            FireOnStatusErrorEvent(tradeStatusType);
            OtherUserCancelled = true;
            return(false);
        }
Beispiel #5
0
        /// <summary>
        /// This updates the trade.  This is called at an interval of a
        /// default of 800ms, not including the execution time of the
        /// method itself.
        /// </summary>
        /// <returns><c>true</c> if the other trade partner performed an action; otherwise <c>false</c>.</returns>
        public bool Poll()
        {
            if (!TradeStarted)
            {
                TradeStarted = true;

                // since there is no feedback to let us know that the trade
                // is fully initialized we assume that it is when we start polling.
                if (OnAfterInit != null)
                {
                    OnAfterInit();
                }
            }

            TradeStatus status = RetryWebRequest(session.GetStatus);

            if (status == null)
            {
                return(false);
            }

            TradeStatusType tradeStatusType = (TradeStatusType)status.trade_status;

            switch (tradeStatusType)
            {
            // Nothing happened. i.e. trade hasn't closed yet.
            case TradeStatusType.OnGoing:
                return(HandleTradeOngoing(status));

            // Successful trade
            case TradeStatusType.CompletedSuccessfully:
                HasTradeCompletedOk = true;
                return(false);

            //On a status of 2, the Steam web code attempts the request two more times
            //This is our attempt to do the same.  I (BlueRaja) personally don't think this will work, but we shall see...
            case TradeStatusType.UnknownStatus:
                numUnknownStatusUpdates++;
                if (numUnknownStatusUpdates < 3)
                {
                    return(false);
                }
                break;
            }

            FireOnStatusErrorEvent(tradeStatusType);
            OtherUserCancelled = true;
            return(false);
        }