|
Plotly.cpp 0.1.0
A C++ plotting library for expressive, interactive, real-time & streaming data visualization
|
Abstract interface for WebSocket endpoints. More...
#include <websockets_endpoint.hpp>

Public Types | |
| using | callback_t = std::function<void(const std::string_view &)> |
| Callback function type for handling incoming messages. | |
Public Member Functions | |
| WebsocketEndpointInterface () | |
| Default constructor. | |
| virtual | ~WebsocketEndpointInterface () |
| Virtual destructor. | |
| WebsocketEndpointInterface (const WebsocketEndpointInterface &)=delete | |
| Copy constructor (deleted) | |
| auto | operator= (const WebsocketEndpointInterface &) -> WebsocketEndpointInterface &=delete |
| Copy assignment operator (deleted) | |
| virtual auto | waitConnection (std::chrono::milliseconds timeout) const -> bool=0 |
| Wait for a connection to be established. | |
| virtual auto | isConnected () const -> bool=0 |
| Check if the endpoint is currently connected. | |
| virtual auto | send (const std::string_view &message) -> bool=0 |
| Send a message through the WebSocket connection. | |
| virtual void | registerCallback (const std::string_view &eventName, callback_t callback)=0 |
| Register a callback for a specific event. | |
| virtual void | unregisterCallback (const std::string_view &eventName)=0 |
| Unregister a callback for a specific event. | |
| virtual void | stop ()=0 |
| Stop the endpoint and clean up resources. | |
| virtual auto | getName () const -> std::string=0 |
| Get the name/identifier of this endpoint. | |
Abstract interface for WebSocket endpoints.
This class defines the common interface for both client and server WebSocket endpoints. It provides methods for connection management, message sending, event callbacks, and lifecycle management.
The interface is designed to be thread-safe and supports asynchronous operation with callback-based event handling.
| using plotly::detail::WebsocketEndpointInterface::callback_t = std::function<void(const std::string_view &)> |
Callback function type for handling incoming messages.
| message | The received message |
|
default |
Default constructor.
|
virtualdefault |
Virtual destructor.
|
delete |
Copy constructor (deleted)
|
nodiscardpure virtual |
Get the name/identifier of this endpoint.
This method returns a human-readable name or identifier for the endpoint, useful for logging and debugging purposes.
Implemented in plotly::detail::WebsocketClient, and plotly::detail::WebsocketServer.
|
nodiscardpure virtual |
Check if the endpoint is currently connected.
This method provides a non-blocking way to check the current connection status of the endpoint.
Implemented in plotly::detail::WebsocketClient, and plotly::detail::WebsocketServer.
|
delete |
Copy assignment operator (deleted)
|
pure virtual |
Register a callback for a specific event.
| eventName | The name of the event to listen for |
| callback | The callback function to invoke when the event occurs |
This method registers a callback function that will be called when a message with the specified event name is received. Only one callback can be registered per event name.
Implemented in plotly::detail::WebsocketEndpointImpl.
|
pure virtual |
Send a message through the WebSocket connection.
| message | The message to send |
This method attempts to send a message through the WebSocket connection. The operation may fail if the connection is not established or if there are network issues.
Implemented in plotly::detail::WebsocketClient, and plotly::detail::WebsocketServer.
|
pure virtual |
Stop the endpoint and clean up resources.
This method stops all endpoint operations, closes connections, and performs necessary cleanup. After calling this method, the endpoint should not be used for further operations.
Implemented in plotly::detail::WebsocketClient, and plotly::detail::WebsocketServer.
|
pure virtual |
Unregister a callback for a specific event.
| eventName | The name of the event to stop listening for |
This method removes the callback associated with the specified event name. After calling this method, no callback will be invoked for the event.
Implemented in plotly::detail::WebsocketEndpointImpl.
|
nodiscardpure virtual |
Wait for a connection to be established.
| timeout | Maximum time to wait for connection |
This method blocks until either a connection is established or the timeout expires. It's useful for synchronizing with connection establishment in client scenarios or waiting for incoming connections in server scenarios.
Implemented in plotly::detail::WebsocketClient, and plotly::detail::WebsocketServer.