summaryrefslogtreecommitdiff
path: root/include/tgbot/net/TgLongPoll.h
blob: 8e62cd135644c0eb5cd46831dc259f414ed62306 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef TGBOT_TGLONGPOLL_H
#define TGBOT_TGLONGPOLL_H

#include "tgbot/Bot.h"
#include "tgbot/Api.h"
#include "tgbot/EventHandler.h"

namespace TgBot {

/**
 * @brief This class handles long polling and updates parsing.
 *
 * @ingroup net
 */
class TgLongPoll {

public:
    TgLongPoll(const Api* api, const EventHandler* eventHandler, int32_t, int32_t, const std::shared_ptr<std::vector<std::string>>&);
    TgLongPoll(const Bot& bot, int32_t = 100, int32_t = 10, const std::shared_ptr<std::vector<std::string>>& = 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.
     */
    void start();

private:
    const Api* _api;
    const EventHandler* _eventHandler;
    int32_t _lastUpdateId = 0;
    int32_t _limit;
    int32_t _timeout;
    std::shared_ptr<std::vector<std::string>> _allowupdates;
};

}

#endif //TGBOT_TGLONGPOLL_H