#include "WHISPER/InternalUDPService.hpp" #include "WHISPER/Messages/Message.hpp" #include "WHISPER/Messages/stringData.hpp" #include #include #include #include #include /// 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; } } #define ID 1 int main() { // 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::SourceType::SHIP,8000,"192.168.1.178"); auto receiver = std::make_shared>(); WHISPER::InternalUDPService service("01",8000,"192.168.1.255","192.168.1.178"); service.connect(receiver); service.subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::DATA]); // service.subscribe(WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]); WHISPER::StringData data("01","hello world"); service.publish(data.serialize(), WHISPER::MsgTopicsMap[WHISPER::MsgTopics::DATA]); // WHISPER::RawTrack RawTrack(ID,WHISPER::MsgTopics::TRACK,WHISPER::SourceType::SHIP,0001); // std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // service.publish(RawTrack.serialize(),WHISPER::MsgTopicsMap[WHISPER::MsgTopics::TRACK]); while (running) { service.publish(data.serialize(), WHISPER::MsgTopicsMap[WHISPER::MsgTopics::DATA]); std::this_thread::sleep_for(std::chrono::milliseconds(1000)); } service.disconnect(); return 0; }