Added 30-second delay on stream error

This commit is contained in:
tastytea 2018-05-26 11:14:08 +02:00
parent c6153d98e0
commit 95c9eea3df
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
2 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7)
project (expandurl-mastodon
VERSION 0.6.4
VERSION 0.6.5
LANGUAGES CXX
)

View File

@ -110,12 +110,19 @@ const void Listener::start()
{
_thread = std::thread([=]
{
std::uint_fast16_t ret = 0;
_running = true;
Easy masto(_instance, _access_token);
masto.set_useragent(static_cast<const string>("expandurl-mastodon/") +
global::version);
masto.get_stream(Mastodon::API::v1::streaming_user, _stream, _ptr);
ret = masto.get_stream(Mastodon::API::v1::streaming_user, _stream, _ptr);
syslog(LOG_DEBUG, "Connection lost.");
if (ret != 0 && ret != 14) // 14 means canceled by user
{
syslog(LOG_ERR, "Connection terminated: Error %u", ret);
syslog(LOG_INFO, "Waiting for 30 seconds");
std::this_thread::sleep_for(std::chrono::seconds(30));
}
_running = false;
});
while (_ptr == nullptr)