Files
whisper-com/include/WHISPER/InternalUDPService.hpp
2022-11-13 15:04:20 +01:00

66 lines
1.4 KiB
C++

#pragma once
#include "WHISPER/whisper.hpp"
#include <cstdint>
#include <list>
#include <memory>
#include <vector>
#define ZMQ_BUILD_DRAFT_API 1
#include <zmq.hpp>
#include <zmq_addon.hpp>
namespace WHISPER {
struct localClient{
short port;
zmq::socket_t clientSocket;
};
class InternalUDPService : public whispercomm {
private:
std::string destinationAdress_;
std::string myAdress_;
std::uint16_t port_;
std::uint16_t ownReceivingPort_;
zmq::context_t ctx;
zmq::socket_t sender;
std::shared_ptr<zmq::socket_t> receiver = nullptr;
std::shared_ptr<zmq::socket_t> loopbackSocket = nullptr;
std::vector<std::shared_ptr<localClient>> localclients;
std::uint16_t checkPort(std::uint16_t port);
void derivedConnect() override;
void derivedDisconnect() override;
void derivedPublish(std::string msg,std::string topic) override;
void derivedReceive() override;
void derivedSubscribe(std::string topic) override;
void derivedUnsubscribe(std::string topic) override;
public:
InternalUDPService(std::uint32_t id, SourceType owndevicetype,std::uint16_t port, std::string destinationAdress, std::string myAdress);
};
}