summaryrefslogtreecommitdiff
path: root/src/remoteauth/remoteauthclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/remoteauth/remoteauthclient.cpp')
-rw-r--r--src/remoteauth/remoteauthclient.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/remoteauth/remoteauthclient.cpp b/src/remoteauth/remoteauthclient.cpp
index c0a06d9..083bdaa 100644
--- a/src/remoteauth/remoteauthclient.cpp
+++ b/src/remoteauth/remoteauthclient.cpp
@@ -34,6 +34,7 @@ void RemoteAuthClient::Stop() {
}
m_connected = false;
+ if (m_timeout_conn) m_timeout_conn.disconnect();
m_ws.Stop(1000);
m_heartbeat_waiter.kill();
if (m_heartbeat_thread.joinable()) m_heartbeat_thread.join();
@@ -44,6 +45,7 @@ bool RemoteAuthClient::IsConnected() const noexcept {
}
void RemoteAuthClient::OnGatewayMessage(const std::string &str) {
+ m_log->trace(str);
auto j = nlohmann::json::parse(str);
const auto opcode = j.at("op").get<std::string>();
if (opcode == "hello") {
@@ -67,6 +69,8 @@ void RemoteAuthClient::HandleGatewayHello(const nlohmann::json &j) {
m_heartbeat_msec = heartbeat_interval;
m_heartbeat_thread = std::thread(&RemoteAuthClient::HeartbeatThread, this);
+ m_timeout_conn = Glib::signal_timeout().connect(sigc::mem_fun(*this, &RemoteAuthClient::OnTimeout), timeout_ms);
+
Init();
m_signal_hello.emit();
@@ -294,6 +298,13 @@ void RemoteAuthClient::OnDispatch() {
OnGatewayMessage(msg);
}
+bool RemoteAuthClient::OnTimeout() {
+ m_log->trace("Socket timeout");
+ Stop();
+ Start();
+ return false; // disconnect
+}
+
RemoteAuthClient::type_signal_hello RemoteAuthClient::signal_hello() {
return m_signal_hello;
}