implemented local client join functionality

This commit is contained in:
Henry Winkel
2022-11-13 15:04:20 +01:00
parent 84305eb7fa
commit cf1800ffba
9 changed files with 231 additions and 40 deletions

61
src/mainRecv.cpp Normal file
View File

@@ -0,0 +1,61 @@
#include "zmq.hpp"
#include <iostream>
#include <loguru.hpp>
#include <memory>
#include <thread>
#include <WHISPER/InternalUDPService.hpp>
#include <WHISPER/Messages/Join.hpp>
/// variable for stopping the application
bool running = true;
/**
* @brief killhandler to set running to false on CTRL-C
*
* @param s - the signal to manage
*/
void killHandlerPing(int s) {
if (s == SIGINT) {
running = false;
}
}
int main()
{
// zmq::context_t ctx(2);
// zmq::socket_t sock(ctx,zmq::socket_type::dish);
// sock.bind("udp://*:8000");
// zmq::message_t temp;
// sock.join("data");
WHISPER::Join join(2,1,WHISPER::MsgType::JOIN,WHISPER::SourceType::SHIP,8000,"192.168.0.19");
auto receiver = std::make_shared<WHISPER::threadSafeQueue<WHISPER::Message>>();
WHISPER::InternalUDPService service(1,WHISPER::SHIP,8000,"192.168.0.255","192.168.0.255");
service.connect(receiver);
service.publish(join.serialize(), "management");
// zmq::context_t ctx(2);
// zmq::socket_t sock(ctx,zmq::socket_type::radio);
// sock.connect("udp://127.0.0.1:8000");
// std::string string = "hello world form 2";
while (running) {
// LOG_S(INFO)<<"received messages " << receiver->size();
service.publish(join.serialize(), "management");
// zmq::message_t msg(string.begin(),string.end());
// msg.set_group("management");
// sock.send(msg,zmq::send_flags::none);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
return 0;
}