Fix write connection reconnection issues (#2850)
Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <IrcConnection>
|
||||
#include <QTimer>
|
||||
#include <chrono>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -12,14 +13,27 @@ class IrcConnection : public Communi::IrcConnection
|
||||
public:
|
||||
IrcConnection(QObject *parent = nullptr);
|
||||
|
||||
pajlada::Signals::NoArgSignal reconnectRequested;
|
||||
// Signal to notify that we're unexpectedly no longer connected, either due
|
||||
// to a connection error or if we think we've timed out. It's up to the
|
||||
// receiver to trigger a reconnect, if desired
|
||||
pajlada::Signals::Signal<bool> connectionLost;
|
||||
|
||||
// Request a reconnect with a minimum interval between attempts.
|
||||
pajlada::Signals::NoArgSignal smartReconnect;
|
||||
|
||||
virtual void open();
|
||||
virtual void close();
|
||||
|
||||
private:
|
||||
QTimer pingTimer_;
|
||||
QTimer reconnectTimer_;
|
||||
std::atomic<bool> recentlyReceivedMessage_{true};
|
||||
std::chrono::steady_clock::time_point lastConnected_;
|
||||
|
||||
// waitingForPong_ is set to true when we send a PING message, and back to false when we receive the matching PONG response
|
||||
std::atomic<bool> expectConnectionLoss_{false};
|
||||
|
||||
// waitingForPong_ is set to true when we send a PING message, and back to
|
||||
// false when we receive the matching PONG response
|
||||
std::atomic<bool> waitingForPong_{false};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user