FIX: fixed some bugs

ADD: added raw_track message frame
This commit is contained in:
Henry Winkel
2022-11-15 15:55:24 +01:00
parent cf1800ffba
commit 8fcf4244b0
25 changed files with 1799 additions and 158 deletions

View File

@@ -1,5 +1,6 @@
#include "WHISPER/InternalUDPService.hpp"
#include "WHISPER/Messages/Message.hpp"
#include "WHISPER/Messages/Track.hpp"
#include "zmq.hpp"
#include <iostream>
#include <loguru.hpp>
@@ -24,70 +25,57 @@ void killHandlerPing(int s) {
}
}
#define ID 1
int main()
{
// GOOGLE_PROTOBUF_VERIFY_VERSION;
// setup signal handler
struct sigaction sigIntHandler;
sigIntHandler.sa_handler = killHandlerPing;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;
sigaction(SIGINT, &sigIntHandler, NULL);
GOOGLE_PROTOBUF_VERIFY_VERSION;
WHISPER::Join join(1,1,WHISPER::MsgType::JOIN,WHISPER::SourceType::SHIP,8000,"192.168.0.19");
// std::string msg = join.serialize();
// LOG_S(INFO)<<" serialized Message is "<<msg.size();
// LOG_S(INFO)<<msg;
// messages::header::Message proto;
// proto.ParseFromString(msg);
// WHISPER::Message receivedMessage(msg);
// LOG_S(INFO)<<receivedMessage.msgType_;
// switch (receivedMessage.msgType_) {
// case WHISPER::MsgType::JOIN:
// WHISPER::Join receivedJoin(msg);
// LOG_S(INFO)<< "join message data afer reception "<< receivedJoin.port;
// break;
// }
// WHISPER::Join join(1,1,WHISPER::SourceType::SHIP,8000,"192.168.1.178");
auto receiver = std::make_shared<WHISPER::threadSafeQueue<WHISPER::Message>>();
WHISPER::InternalUDPService service(1,WHISPER::SHIP,8000,"192.168.0.255","192.168.0.19");
WHISPER::InternalUDPService service(1,WHISPER::SHIP,8000,"192.168.0.255","192.168.1.178");
service.connect(receiver);
service.publish(join.serialize(), "management");
service.subscribe("data");
service.subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::DATA]);
service.subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]);
// zmq::context_t ctx(2);
// zmq::socket_t sock(ctx,zmq::socket_type::radio);
// sock.connect("udp://127.0.0.255:8000");
// std::string string = "hello world form 2";
// zmq::message_t msg(string.begin(),string.end());
// // memcpy (msg.data (), string.data(), string.size());
// LOG_S(INFO)<<"message contains "<<msg.str();
// 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");
// service.publish(join.serialize(), WHISPER::MsgTopicsMap[WHISPER::MsgTopics::MANAGEMENT]);
WHISPER::RawTrack RawTrack(ID,WHISPER::MsgTopics::TRACK,WHISPER::SourceType::SHIP,0001);
int size = 0;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
service.publish(RawTrack.serialize(),WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]);
while (running) {
// zmq::message_t msg(string.begin(),string.end());
// msg.set_group("data");
// sock.send(msg,zmq::send_flags::none);
// service.publish(join.serialize(), "management");
if (size != receiver->size()) {
LOG_S(INFO)<<"received messages " << size;
size = receiver->size();
}
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
service.disconnect();
return 0;
}