// // Created by zx on 23-4-11. // #ifndef NAVIGATION_TERMINATOR_EMQX_H #define NAVIGATION_TERMINATOR_EMQX_H #include #include "emqx/paho_client.h" #include "emqx/message.grpc.pb.h" typedef void (*Callback)(const MqttMsg& msg,void* context); typedef struct{ Callback func; void* contextx; }CallBackInfo; class Terminator_emqx { public: Terminator_emqx(std::string nodeId); virtual ~Terminator_emqx(); bool Connect(std::string ip,int port); bool AddCallback(std::string topic,Callback callback,void* context); void Publish(std::string topic,const MqttMsg& statu); protected: static void MessageArrivedCallback(std::string topic,int QOS,MqttMsg& msg,void* context); std::mutex mtx_; Paho_client* client_; bool connected_; std::string nodeId_; public: std::map sub_topic_callbacks_; }; #endif //NAVIGATION_TERMINATOR_EMQX_H