ADD: added message callback to udp listener

This commit is contained in:
Henry Winkel
2023-08-16 15:01:23 +02:00
parent aa7418ebc9
commit f794f4c5d0
7 changed files with 42 additions and 19 deletions

View File

@@ -9,6 +9,7 @@
#include <memory>
#include <vector>
#include <WHISPER/localClients.hpp>
#include <future>
#define ZMQ_BUILD_DRAFT_API 1
#include <zmq.hpp>
@@ -18,6 +19,22 @@ namespace WHISPER {
class InternalUDPListener{
public:
InternalUDPListener(std::uint16_t port);
~InternalUDPListener();
void connect(std::shared_ptr<threadSafeQueue<WHISPER::Message>> receiver);
void start();
void stop();
std::uint16_t getPort();
void subscribe(WHISPER::MsgTopics topic);
void unsubscribe(WHISPER::MsgTopics topic);
void registerMessageCallback(std::function<void(std::string)> MessageHandle);
private:
std::uint16_t port_;
//zeromq io contex
@@ -38,17 +55,8 @@ namespace WHISPER {
std::uint16_t checkPort(std::uint16_t port);
public:
InternalUDPListener(std::uint16_t port);
~InternalUDPListener();
void connect(std::shared_ptr<threadSafeQueue<WHISPER::Message>> receiver);
void start();
void stop();
std::uint16_t getPort();
void subscribe(WHISPER::MsgTopics topic);
void unsubscribe(WHISPER::MsgTopics topic);
std::function<void(std::string)> MessageHandle_ = nullptr;
std::atomic_bool useHandl_ = false;;

View File

@@ -34,6 +34,7 @@ namespace WHISPER {
public:
InternalUDPService(std::string id, std::uint16_t port, std::string destinationAdress, std::string myAdress);
~InternalUDPService();
private:
/// ip address of the destination