Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Polling< T > Class Template Reference

Handle long (or short) polling for a bot. More...

#include <polling.hpp>

Public Member Functions

 Polling (T bot, uint_fast8_t threads_number, uint_fast32_t limit=100, uint_fast32_t timeout=60)
 Create a polling object by passing a single bot, and the number of threads. More...
 
 Polling (std::vector< T > bots, uint_fast32_t limit=100, uint_fast32_t timeout=60)
 Create a polling object by passing a vector of bots of the same type. More...
 
void run ()
 Start the polling.
 

Private Member Functions

uint_fast32_t firstUpdateID (T &poller)
 Get the offset of the first update to process. More...
 
void init ()
 Init logger for each bot. More...
 

Private Attributes

std::vector< T > bots
 Vector of bots.
 
moodycamel::BlockingConcurrentQueue< types::Update > updates_queue
 Queue of the updates to process.
 
std::shared_ptr< spdlog::logger > console_stderr
 Logger that will print error messages to the console.
 
std::shared_ptr< spdlog::logger > console_stdout
 Logger that will print messages to the console.
 

Detailed Description

template<class T>
class cppgram::Polling< T >

Handle long (or short) polling for a bot.

Constructor & Destructor Documentation

◆ Polling() [1/2]

Polling ( bot,
uint_fast8_t  threads_number,
uint_fast32_t  limit = 100,
uint_fast32_t  timeout = 60 
)

Create a polling object by passing a single bot, and the number of threads.

Parameters
botBot that will handle updates.
threads_numberNumber of threads that will run asynchronously.
limitLimits the number of updates to be retrieved. Values between 1—100 are accepted.
timeoutTimeout in seconds for long polling. Defaults to 0, i.e. usual short polling.

◆ Polling() [2/2]

Polling ( std::vector< T >  bots,
uint_fast32_t  limit = 100,
uint_fast32_t  timeout = 60 
)

Create a polling object by passing a vector of bots of the same type.

Parameters
botsVector of bots that will run asynchronously.
limitLimits the number of updates to be retrieved. Values between 1—100 are accepted.
timeoutTimeout in seconds for long polling. Defaults to 0, i.e. usual short polling.

Member Function Documentation

◆ firstUpdateID()

uint_fast32_t firstUpdateID ( T &  poller)
private

Get the offset of the first update to process.

Returns
Update offset.

◆ init()

void init ( )
private

Init logger for each bot.


The documentation for this class was generated from the following files: