Files
mbft-cpp/connectors/tgbot-cpp/TgbotCppConnector.h
T

33 lines
985 B
C++
Raw Normal View History

2026-07-15 12:02:55 +03:00
#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;
};
}