Squashed 'libs/CommService/' content from commit 7ccc0fc
git-subtree-dir: libs/CommService git-subtree-split: 7ccc0fce88bbc5969df060058cf0fb57abe3bcf9
This commit is contained in:
53
src/main.cpp
Normal file
53
src/main.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "CommService/Message.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <csignal>
|
||||
|
||||
#include <CommService/Convert.hpp>
|
||||
#include <CommService/CommService.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(){
|
||||
// setup signal handler
|
||||
struct sigaction sigIntHandler;
|
||||
sigIntHandler.sa_handler = killHandlerPing;
|
||||
sigemptyset(&sigIntHandler.sa_mask);
|
||||
sigIntHandler.sa_flags = 0;
|
||||
sigaction(SIGINT, &sigIntHandler, NULL);
|
||||
|
||||
|
||||
|
||||
|
||||
CommService::CommService UDPService("127.0.0.255","127.0.0.1",1,CommService::WAR_SHIP,"F124",8000);
|
||||
UDPService.connect();
|
||||
auto msgQueue = UDPService.getReceivedMessageQueue();
|
||||
|
||||
while (running) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
UDPService.stop();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user