diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/net/BoostHttpOnlySslClient.cpp | 2 | ||||
-rw-r--r-- | src/net/CurlHttpClient.cpp | 2 | ||||
-rw-r--r-- | src/net/TgLongPoll.cpp | 17 |
3 files changed, 10 insertions, 11 deletions
diff --git a/src/net/BoostHttpOnlySslClient.cpp b/src/net/BoostHttpOnlySslClient.cpp index 6e59649..82bd897 100644 --- a/src/net/BoostHttpOnlySslClient.cpp +++ b/src/net/BoostHttpOnlySslClient.cpp @@ -52,7 +52,7 @@ string BoostHttpOnlySslClient::makeRequest(const Url& url, const vector<HttpReqA struct timeval timeStruct; // set the timeout to 20 seconds - timeStruct.tv_sec = 20; + timeStruct.tv_sec = _timeout; timeStruct.tv_usec = 0; FD_ZERO(&fileDescriptorSet); diff --git a/src/net/CurlHttpClient.cpp b/src/net/CurlHttpClient.cpp index 2a397f9..c487898 100644 --- a/src/net/CurlHttpClient.cpp +++ b/src/net/CurlHttpClient.cpp @@ -11,7 +11,7 @@ CurlHttpClient::CurlHttpClient() : _httpParser() { curlSettings = curl_easy_init(); curl_easy_setopt(curlSettings, CURLOPT_CONNECTTIMEOUT, 20); - curl_easy_setopt(curlSettings, CURLOPT_TIMEOUT, 25); + curl_easy_setopt(curlSettings, CURLOPT_TIMEOUT, _timeout); } CurlHttpClient::~CurlHttpClient() { diff --git a/src/net/TgLongPoll.cpp b/src/net/TgLongPoll.cpp index 6a224cb..70333dd 100644 --- a/src/net/TgLongPoll.cpp +++ b/src/net/TgLongPoll.cpp @@ -12,20 +12,19 @@ namespace TgBot { TgLongPoll::TgLongPoll(const Api* api, const EventHandler* eventHandler, std::int32_t limit, std::int32_t timeout, std::shared_ptr<std::vector<std::string>> allowUpdates) - : _api(api), _eventHandler(eventHandler), _limit(limit), _timeout(timeout), - _allowUpdates(std::move(allowUpdates)) { + : _api(api), _eventHandler(eventHandler), _limit(limit), _timeout(timeout) + , _allowUpdates(std::move(allowUpdates)) { + + const_cast<TgBot::HttpClient&>(_api->_httpClient)._timeout = _timeout + 5; } -TgLongPoll::TgLongPoll(const Bot& bot, std::int32_t limit, std::int32_t timeout, const std::shared_ptr<std::vector<std::string>>& allowUpdates) : - TgLongPoll(&bot.getApi(), &bot.getEventHandler(), limit, timeout, allowUpdates) { +TgLongPoll::TgLongPoll(const Bot& bot, std::int32_t limit, std::int32_t timeout, const std::shared_ptr<std::vector<std::string>>& allowUpdates) + : TgLongPoll(&bot.getApi(), &bot.getEventHandler(), limit, timeout, allowUpdates) { } void TgLongPoll::start() { - // get all unconfirmed updates - std::vector<Update::Ptr> updates = _api->getUpdates(0, _limit, _timeout, _allowUpdates); - // handle updates - for (Update::Ptr& item : updates) { + for (Update::Ptr& item : _updates) { if (item->updateId >= _lastUpdateId) { _lastUpdateId = item->updateId + 1; } @@ -33,7 +32,7 @@ void TgLongPoll::start() { } // confirm handled updates - _api->getUpdates(_lastUpdateId, _limit, _timeout, _allowUpdates); + _updates = _api->getUpdates(_lastUpdateId, _limit, _timeout, _allowUpdates); } } |