-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrackingServer.hpp
More file actions
72 lines (58 loc) · 1.93 KB
/
TrackingServer.hpp
File metadata and controls
72 lines (58 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef __TRACKINGSERVER_HPP_
#define __TRACKINGSERVER_HPP_
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <unistd.h>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <thread>
#include <mutex>
#include <sys/un.h>
#include <future>
#include "loguru.hpp"
#include "utils.hpp"
#include "settings.hpp"
#include "AbstractReliableBroadcast.hpp"
#include "common.hpp"
#include "TrackPacket.hpp"
typedef std::map<uint8_t, std::pair<Position, uint32_t>> nodemap_t;
class TrackingServer final : public AbstractReliableBroadcastNode<TrackPacket> {
private:
// self information and settings
const unsigned short _peer_lost_timeout = TRACKING_PEER_LOSS_TIMEOUT;
// Unix Socket Sender
const char* _usocket_path = FP_USOCKET_PATH;
struct sockaddr_un _flight_server_addr;
int _usockfd;
void _setup_usocket();
void _send_status_node_map(bool);
std::string _get_json_nodemap(const nodemap_t& map, bool is_new_poly);
std::mutex _mutex_status_node_map;
nodemap_t _status_node_map;
// threads
std::thread _thread_check_node_map;
void _tr_check_node_map();
std::thread _thread_heartbeat;
void _tr_heartbeat();
TrackPacket _produce_packet() override;
virtual void _process_packet(const TrackPacket&) override;
bool _received_first_poly=false;
std::thread _thread_update_poly;
void _tr_update_poly();
std::mutex _mutex_json_global_poly;
std::array<char, TRACKING_GLOBALPOLY_MAXBUF> _json_global_poly;
uint16_t _polyid=0;
public:
TrackingServer(unsigned short port, uint8_t nodeID);
TrackingServer(const TrackingServer&) = delete;
TrackingServer(TrackingServer&&) = delete;
TrackingServer& operator=(const TrackingServer&) = delete;
TrackingServer& operator=(const TrackingServer&&) = delete;
virtual ~TrackingServer();
virtual void start() override;
virtual void join() override;
};
#endif