This class handles long polling and updates parsing.
More...
#include <TgLongPoll.h>
|
| using | ErrorHandler = std::function<void(const std::exception&)> |
|
| | 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) |
| void | start () |
| | Performs one long-polling iteration and dispatches received updates. Parses received updates and passes them to EventHandler, which invokes the registered listeners.
|
| void | startLoop (const ErrorHandler &errorHandler={ }, std::initializer_list< int > signals={ SIGINT, SIGTERM }) |
| | Polls for updates until stop() is called, one of the configured signals is received, or an unhandled error occurs.
|
| void | stop () |
| | Requests cancellation of the active HTTP request and stops startLoop().
|
| bool | isRunning () const |
| | Returns true while startLoop() is active.
|
This class handles long polling and updates parsing.
Definition at line 27 of file TgLongPoll.h.
◆ ErrorHandler
◆ TgLongPoll() [1/2]
| 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 ) |
◆ TgLongPoll() [2/2]
| TgBot::TgLongPoll::TgLongPoll |
( |
const Bot & | bot, |
|
|
std::int32_t | limit = 100, |
|
|
std::int32_t | timeout = 10, |
|
|
const std::shared_ptr< std::vector< std::string > > & | allowUpdates = nullptr ) |
◆ isRunning()
| bool TgBot::TgLongPoll::isRunning |
( |
| ) |
const |
|
inline |
◆ start()
| void TgBot::TgLongPoll::start |
( |
| ) |
|
Performs one long-polling iteration and dispatches received updates. Parses received updates and passes them to EventHandler, which invokes the registered listeners.
◆ startLoop()
| void TgBot::TgLongPoll::startLoop |
( |
const ErrorHandler & | errorHandler = { }, |
|
|
std::initializer_list< int > | signals = { SIGINT, SIGTERM } ) |
Polls for updates until stop() is called, one of the configured signals is received, or an unhandled error occurs.
- Parameters
-
| errorHandler | Called when a polling iteration fails. The loop continues after the handler returns. If no handler is provided, the exception is propagated. |
| signals | Process signals that stop the loop. Pass an empty list to disable signal handling. |
◆ stop()
| void TgBot::TgLongPoll::stop |
( |
| ) |
|
Requests cancellation of the active HTTP request and stops startLoop().
The documentation for this class was generated from the following file: