Fix write connection reconnection issues #2850
Chatterino currently does not handle disconnects of the write connection, which causes messages to remain buffered until you manually reconnect, after which it will send all messages at once. This patch addresses the lack of reconnection specifically, and attempts to refactor some of the reconnection logic to make it more robust. Backoff behavior is introduced to *both* read/write cons to avoid reconnection loops. To replicate the issue, simply lose your (write) connection to TMI. This can be "simulated" using something like: tcpkill -i eth0 host 184.108.40.206 or host 220.127.116.11 or host 18.104.22.168 An alternative/secondary approach would be to detect failures of the underlying `sendRaw` method (as it returns false if the message can't be sent to the connection), but better monitoring of the connection state should be sufficient. The way the code is setup currently doesn't really make it easy to implement this "cleanly". E.g. calls `initializeConnection` are skipped on reconnect, but since we're reconnecting with the same parameters, this should have little actual consequence.
Account switching (including updating your own OAuth token) doesn't work properly, because the disconnect triggered by
Working on a fix.
Avoids an already running pingTimer being called early in the connection and ensures we're always in a sensible state when opening a connection. Improve comments as requested.
Now we're on commit 2f568b8; Changes from upstream we pulled: - Minor: Searching for users in the viewer list now searches anywhere in the user's name. (Chatterino#2861) - Minor: Now shows deletions of messages like timeouts (Chatterino#1155, Chatterino#2841) - Minor: Added a link to accounts page in settings to "You need to be logged in to send messages" message. (Chatterino#2862) - Minor: Switch to Twitch v2 emote API for animated emote support. (Chatterino#2863) - Bugfix: Fix reconnecting when IRC write connection is lost (Chatterino#1831, Chatterino#2356, Chatterino#2850) - Bugfix: Fixed bit emotes not loading in some rare cases. (Chatterino#2856)
Now we're on commit 0021290; Changes from upstream we pulled: - Bugfix: Fix reconnecting when IRC write connection is lost (Chatterino#1831, Chatterino#2356, Chatterino#2850, Chatterino#2892) - Bugfix: Fixed subscription emotes showing up incorrectly in the emote menu. (Chatterino#2905) Changes added in Chatterino7 only: - Major: Added 7tv badges. (2154981) - Minor: Fixed potential issues preventing 7tv emotes from loading (c0b1117)