opentibiabr / otcv8

OTCv8 for OpenTibia Community.
Other
11 stars 20 forks source link

fix: BotServer #9

Open luanluciano93 opened 3 months ago

luanluciano93 commented 3 months ago

credits: @Leesneaks

Leesneaks commented 3 months ago

There's also an issue where the Bot server doesn't clear out the websockets on clear() as it .cancel(socket) where socket is always 1, yet the index is the actual operation ID.

This makes sure it clears it from HTTP.operations as well. The next connection will still keep the older index as this is done within the client int operationId = m_operationId++;

I've had no issues with it. https://github.com/Leesneaks/otclientv8/commit/119f93d50ae657899d81d24ac49ecc7444d22571

Leesneaks commented 2 months ago

@luanluciano93 I removed the onopen. Whilst it works,, whilst updating my botserver, I noticed there's a way to crash people (not instantly) via BotServer and it'll cause an infinite loop spamming the warn messages.

I updated it slightly in this https://github.com/Leesneaks/otclientv8/commit/a5a266153c3116ab45307016f90008735b180698 by using onError to look for resolve error, this way if it can't connect it'll just stop trying. rather than looping. This works well for me, but i could see some issues with people with bad internet having an issue or two.

Could be modified to try to reconnect a few times on resolve error, rather than 10x but thats down to whoever wants to include it.