Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tradeoffers events get attached multiple times #19

Open
Koenig4443 opened this issue Jun 20, 2016 · 2 comments
Open

Tradeoffers events get attached multiple times #19

Koenig4443 opened this issue Jun 20, 2016 · 2 comments

Comments

@Koenig4443
Copy link

My bots started behaving odd after running for a while - TradeOfferAccepted , TradeOfferNeedsConfirmation etc was beeing fired multiple times on the same offer. At first i thought it might be related to some threading i have implemented but im pretty sure its not.

One of the major issues with this was that when TradeOfferNeedsConfirmation was beeing called 2nd time it would fail (because it was allready confirmed 1st time this code ran) .. and because of this it would instantly cancel the trade.

i narrowed the problem down to the code in UserWebLogOn() beeing flawed i think:

        TradeOffers = new TradeOffers(SteamUser.SteamID, SteamWeb, ApiKey, TradeOfferRefreshRate);
        TradeOffers.TradeOfferChecked += TradeOffers_TradeOfferChecked;
        TradeOffers.TradeOfferReceived += TradeOffers_TradeOfferReceived;
        TradeOffers.TradeOfferAccepted += TradeOffers_TradeOfferAccepted;
        TradeOffers.TradeOfferDeclined += TradeOffers_TradeOfferDeclined;
        TradeOffers.TradeOfferCanceled += TradeOffers_TradeOfferCanceled;            
        TradeOffers.TradeOfferInvalid += TradeOffers_TradeOfferInvalid;
        TradeOffers.TradeOfferNeedsConfirmation += TradeOffers_TradeOfferNeedsConfirmation;
        TradeOffers.TradeOfferInEscrow += TradeOffers_TradeOfferInEscrow;
        TradeOffers.TradeOfferNoData += TradeOffers_TradeOfferNoData;

here it creates a new tradeoffers handler every time it logs in, and hooks up the functions , but it does not take into account that it might be a re-login. so the old tradeoffers handler (this is running on its own thread) keeps running in the background causing double polling of the offers.

a quick fix is to simply add the following code before hooking up the new tradeOffers object :
if (TradeOffers != null)
{
TradeOffers.StopCheckingPendingTradeOffers();
}

im pretty sure this will cause the background threads to all exit ok, but there might be better cleanup needed.

@voz261
Copy link

voz261 commented Jan 26, 2017

same here ! my bot check multiple times on the same offer when disconnect and relogin .

quick fix is this ?
http://pastebin.com/Nyc9ULKF

@Koenig4443
Copy link
Author

Hello ,

Yes confirmed. This will fix the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants