Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reconnection with connection being lost
After changes regarding to callbacks handling, we accidentally broke the reconnection logic. In particular, forced connection implicitly did disconnect with disconnect callback, but disconnect callback killed our callbacks handling loop for future connection since it was instructed to not reconnect... Pretty convulated logic. Let's attempt to fix and simplify it. There is no forced connection concept anymore, but rather a new reconnect function which either, triggers reconnection through usual disconnection logic, or connects in edge case if we attempted to reconnect with already disconnnected client. This way the status transition is more predictable, as we Connect() only in 3 cases: - Initial start, including !start command, when we actually spawn the callbacks handling loop - Upon disconnection, if we're configured to reconnect - Reconnection, in case we're already disconnected and can't use above And we use reconnect when: - Failure in heartbeats to detect disconnections sooner - Failure in refreshing access tokens, since if we lose our refresh token then the only way to get a new one is to reconnect And finally disconnect is triggered when: - Stopping the bot, especially !stop - Bulletproofing against trying to connect when !KeepRunning and likewise - Usual Steam maintenance and other network issues (which usually trigger reconnection) The codebase is too huge to analyze every possible edge case, but with this logic I can no longer reproduce the previous issue
- Loading branch information