Add tgbot-cpp connector
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <memory>
|
||||
|
||||
#include "connectors/IConnector.h"
|
||||
#include "external/tgbot-cpp/include/tgbot/tgbot.h"
|
||||
#include "connectors/Types.h"
|
||||
#include "core/inc/ThreadSafeQueue.h"
|
||||
|
||||
namespace MBFT
|
||||
{
|
||||
class TgbotCppConnector : public IConnector
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<TgBot::Bot> bot;
|
||||
MBFT::ThreadSafeQueue<std::shared_ptr<MBFT::OutboundMessage>> sendQ;
|
||||
MBFT::ThreadSafeQueue<std::shared_ptr<MBFT::InboundMessage>> recvQ;
|
||||
std::thread inbound_thread;
|
||||
std::thread outbound_thread;
|
||||
|
||||
void inbound_message_callback(TgBot::Message::Ptr message);
|
||||
static void inbound_message_thread(TgBot::Bot& bot);
|
||||
static void outbound_message_thread(TgBot::Bot& bot, MBFT::ThreadSafeQueue<std::shared_ptr<MBFT::OutboundMessage>>& q);
|
||||
public:
|
||||
TgbotCppConnector(void);
|
||||
virtual std::shared_ptr<MBFT::InboundMessage> receive(void) override;
|
||||
virtual void send(std::shared_ptr<MBFT::OutboundMessage>& msg) override;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user