HORIBA C++ SDK
Library for HORIBA devices
Loading...
Searching...
No Matches
websocket_communicator.h
Go to the documentation of this file.
1#ifndef WEBSOCKET_COMMUNICATOR_H
2#define WEBSOCKET_COMMUNICATOR_H
3
4#include <boost/asio/connect.hpp>
5#include <boost/asio/ip/tcp.hpp>
6#include <boost/beast/core.hpp>
7#include <boost/beast/websocket.hpp>
8#include <iostream>
9
11
12namespace horiba::communication {
13
14class Command;
15class Response;
16
21 public:
29 WebSocketCommunicator(std::string host, std::string port);
30
31 ~WebSocketCommunicator() override = default;
32
36 void open() override;
37
41 void close() override;
47 bool is_open() override;
48
56 Response request_with_response(const Command& command) override;
57
58 private:
59 std::string host;
60 std::string port;
61 boost::asio::io_context context;
62 boost::beast::websocket::stream<boost::asio::ip::tcp::socket> websocket{
63 context};
64};
65} /* namespace horiba::communication */
66
67#endif /* ifndef WEBSOCKET_COMMUNICATOR_H */
Represents a command sent to the ICL.
Definition command.h:13
Interface representing a communication channel with the ICL.
Definition communicator.h:12
Represents a response of the ICL.
Definition response.h:13
void open() override
Opens the communication channel with the ICL.
WebSocketCommunicator(std::string host, std::string port)
Constructs a communication channel with the ICL based on a host and port.
bool is_open() override
Checks if the communication channel is open or not.
Response request_with_response(const Command &command) override
Sends a command to the ICL and returns the response.
void close() override
Closes the communication channel with the ICL.
Definition command.h:9