diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-07-09 21:21:29 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2023-07-09 21:21:29 -0400 |
commit | aaa219ce27561bfe060bee5a4eaba0326bc50412 (patch) | |
tree | 3595c0c4001863f4acc02d758b7b5b1d27e2153c /src/remoteauth/remoteauthclient.cpp | |
parent | e0623281eb7fcdc1d04c44b4cd3a30dbffc97134 (diff) | |
download | abaddon-portaudio-aaa219ce27561bfe060bee5a4eaba0326bc50412.tar.gz abaddon-portaudio-aaa219ce27561bfe060bee5a4eaba0326bc50412.zip |
restart ra ws on timeout
Diffstat (limited to 'src/remoteauth/remoteauthclient.cpp')
-rw-r--r-- | src/remoteauth/remoteauthclient.cpp | 11 |
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; } |