diff options
author | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2023-01-29 14:54:20 +0100 |
---|---|---|
committer | llnulldisk <48621230+llnulldisk@users.noreply.github.com> | 2023-01-29 14:54:20 +0100 |
commit | a8defacf2ba9bc3029b16af48a539553f873866b (patch) | |
tree | 8cea4cad5a8bc15e8213193743111f41a73e1461 /include | |
parent | 443b769670046340e266893e00f947c9ce37462f (diff) |
Fix timeout issues (#251)
Diffstat (limited to 'include')
-rw-r--r-- | include/tgbot/Api.h | 3 | ||||
-rw-r--r-- | include/tgbot/net/HttpClient.h | 2 | ||||
-rw-r--r-- | include/tgbot/net/TgLongPoll.h | 8 |
3 files changed, 9 insertions, 4 deletions
diff --git a/include/tgbot/Api.h b/include/tgbot/Api.h index c3ae922..b34a10d 100644 --- a/include/tgbot/Api.h +++ b/include/tgbot/Api.h @@ -1982,12 +1982,13 @@ public: * @return Returns True if bot is blocked by user */ bool blockedByUser(std::int64_t chatId) const; + + const HttpClient& _httpClient; private: boost::property_tree::ptree sendRequest(const std::string& method, const std::vector<HttpReqArg>& args = std::vector<HttpReqArg>()) const; const std::string _token; - const HttpClient& _httpClient; const TgTypeParser _tgTypeParser; const std::string _url; }; diff --git a/include/tgbot/net/HttpClient.h b/include/tgbot/net/HttpClient.h index a35dd7d..024c8ad 100644 --- a/include/tgbot/net/HttpClient.h +++ b/include/tgbot/net/HttpClient.h @@ -26,6 +26,8 @@ public: * If at least 1 arg is marked as file, the content type of a request will be multipart/form-data, otherwise it will be application/x-www-form-urlencoded. */ virtual std::string makeRequest(const Url& url, const std::vector<HttpReqArg>& args) const = 0; + + std::int32_t _timeout = 25; }; } diff --git a/include/tgbot/net/TgLongPoll.h b/include/tgbot/net/TgLongPoll.h index 417260a..9c50407 100644 --- a/include/tgbot/net/TgLongPoll.h +++ b/include/tgbot/net/TgLongPoll.h @@ -1,6 +1,7 @@ #ifndef TGBOT_TGLONGPOLL_H #define TGBOT_TGLONGPOLL_H +#include "tgbot/Api.h" #include "tgbot/export.h" #include <cstdint> @@ -10,7 +11,6 @@ namespace TgBot { -class Api; class Bot; class EventHandler; @@ -22,8 +22,8 @@ class EventHandler; class TGBOT_API TgLongPoll { public: - TgLongPoll(const Api* api, const EventHandler* eventHandler, std::int32_t, std::int32_t, std::shared_ptr<std::vector<std::string>>); - TgLongPoll(const Bot& bot, std::int32_t = 100, std::int32_t = 10, const std::shared_ptr<std::vector<std::string>>& = nullptr); + TgLongPoll(const Api* api, const EventHandler* eventHandler, std::int32_t limit, std::int32_t timeout, std::shared_ptr<std::vector<std::string>> allowUpdates); + TgLongPoll(const Bot& bot, std::int32_t limit = 100, std::int32_t timeout = 10, const std::shared_ptr<std::vector<std::string>>& allowUpdates = nullptr); /** * @brief Starts long poll. After new update will come, this method will parse it and send to EventHandler which invokes your listeners. Designed to be executed in a loop. @@ -37,6 +37,8 @@ private: std::int32_t _limit; std::int32_t _timeout; std::shared_ptr<std::vector<std::string>> _allowUpdates; + + std::vector<Update::Ptr> _updates; }; } |