-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualizer_client.h
More file actions
34 lines (27 loc) · 945 Bytes
/
visualizer_client.h
File metadata and controls
34 lines (27 loc) · 945 Bytes
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
#ifndef SLAM_DUNK__VISUALIZER_CLIENT_H_
#define SLAM_DUNK__VISUALIZER_CLIENT_H_
#include <arpa/inet.h>
#include <stdint.h>
#include <sys/socket.h>
#include <memory>
#include "absl/status/statusor.h"
#include "absl/types/optional.h"
namespace slam_dunk {
// Encapsulates initializing and sending UDP data to visualizer.
class VisualizerClient {
static constexpr char kMachine[] = "127.0.0.1";
public:
// Creates client for the given port if successful.
static absl::StatusOr<std::unique_ptr<VisualizerClient>> Create(int32_t port);
// Sends text data (usually proto in text format)
absl::optional<int32_t> SendData(absl::string_view data);
// Not copyable
VisualizerClient(const VisualizerClient&) = delete;
VisualizerClient& operator=(const VisualizerClient&) = delete;
private:
VisualizerClient() {}
sockaddr_in server_;
int32_t socket_id_;
};
} // namespace slam_dunk
#endif // SLAM_DUNK__VISUALIZER_CLIENT_H_