1#ifndef PLOTLY_DETAILS_WEBSOCKETS_CLIENT_HPP
2#define PLOTLY_DETAILS_WEBSOCKETS_CLIENT_HPP
4#include "websocketpp/config/asio_no_tls_client.hpp"
5#include "websocketpp/roles/client_endpoint.hpp"
11using client_t = websocketpp::client<client_config>;
22 auto connect(
const std::string_view &endpoint) -> bool;
26 auto waitConnection(std::chrono::milliseconds timeout)
const ->
bool override;
28 auto
send(const std::string_view &message) ->
bool override;
29 auto
getName() const -> std::
string override;
37 std::
string _endpointUri;
38 std::thread _serviceThread;
39 mutable std::mutex _connectionMutex;
40 mutable std::condition_variable _connectionCv;
41 std::atomic<
bool> _connected{
false};
43 void setupClientHandlers();
auto connect(const std::string_view &endpoint) -> bool
Definition websockets_client.cpp:28
WebsocketClient(const WebsocketClient &)=delete
WebsocketClient()
Definition websockets_client.cpp:17
auto waitConnection(std::chrono::milliseconds timeout) const -> bool override
Wait for a connection to be established.
Definition websockets_client.cpp:118
~WebsocketClient()
Definition websockets_client.cpp:26
auto getName() const -> std::string override
Get the name/identifier of this endpoint.
Definition websockets_client.cpp:143
void serviceLoop() override
Pure virtual method for the main service loop.
Definition websockets_client.cpp:109
auto operator=(const WebsocketClient &) -> WebsocketClient &=delete
void stop() override
Stop the endpoint and clean up resources.
Definition websockets_client.cpp:101
auto isConnected() const -> bool override
Check if the endpoint is currently connected.
Definition websockets_client.cpp:125
auto operator=(WebsocketClient &&) -> WebsocketClient &=delete
WebsocketClient(WebsocketClient &&)=delete
auto send(const std::string_view &message) -> bool override
Send a message through the WebSocket connection.
Definition websockets_client.cpp:127
Base implementation class for WebSocket endpoints.
Definition websockets_endpoint.hpp:157
Definition browser.cpp:27
websocketpp::client< client_config > client_t
Definition websockets_client.hpp:11
websocketpp::connection_hdl connection_hdl
Definition websockets_client.hpp:12
websocketpp::config::asio_client client_config
Definition websockets_client.hpp:10
WebSocket endpoint interface and implementation for plotly.cpp.