#include <websockets_server.hpp>
|
| void | serviceLoop () override |
| | Pure virtual method for the main service loop.
|
| void | callbackExecutorLoop () |
| | Main loop for the callback executor thread.
|
| void | handleMessage (const std::string &message) |
| | Handle an incoming message by queuing it for callback processing.
|
| void | startCallbackExecutor () |
| | Start the callback executor thread.
|
|
| using | callback_t = std::function<void(const std::string_view &)> |
| | Callback function type for handling incoming messages.
|
| std::atomic< bool > | running {false} |
| | Atomic flag indicating if the endpoint is running.
|
| std::thread | serviceThread |
| | Service thread for handling WebSocket operations.
|
| std::mutex | recvMessagesMutex |
| | Mutex protecting the received messages queue.
|
| std::condition_variable | recvMessagesCv |
| | Condition variable for notifying about new received messages.
|
| std::queue< std::string > | recvMessages |
| | Queue of received messages waiting to be processed.
|
| std::mutex | callbackMutex |
| | Mutex protecting the callbacks map.
|
| std::unordered_map< std::string, callback_t > | callbacks |
| | Map of event names to their associated callback functions.
|
| std::thread | callbackExecutorThread |
| | Thread for executing callbacks.
|
◆ WebsocketServer() [1/3]
| plotly::detail::WebsocketServer::WebsocketServer |
( |
| ) |
|
◆ ~WebsocketServer()
| plotly::detail::WebsocketServer::~WebsocketServer |
( |
| ) |
|
◆ WebsocketServer() [2/3]
| plotly::detail::WebsocketServer::WebsocketServer |
( |
const WebsocketServer & | | ) |
|
|
delete |
◆ WebsocketServer() [3/3]
◆ getName()
| auto plotly::detail::WebsocketServer::getName |
( |
| ) |
const -> std::string |
|
overridevirtual |
Get the name/identifier of this endpoint.
- Returns
- A string identifying this endpoint
This method returns a human-readable name or identifier for the endpoint, useful for logging and debugging purposes.
Implements plotly::detail::WebsocketEndpointInterface.
◆ getPort()
| auto plotly::detail::WebsocketServer::getPort |
( |
| ) |
const -> int |
◆ hasClient()
| auto plotly::detail::WebsocketServer::hasClient |
( |
| ) |
const -> bool |
◆ isConnected()
| auto plotly::detail::WebsocketServer::isConnected |
( |
| ) |
const -> bool |
|
overridevirtual |
Check if the endpoint is currently connected.
- Returns
- true if connected, false otherwise
This method provides a non-blocking way to check the current connection status of the endpoint.
Implements plotly::detail::WebsocketEndpointInterface.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ send()
| auto plotly::detail::WebsocketServer::send |
( |
const std::string_view & | message | ) |
-> bool |
|
overridevirtual |
Send a message through the WebSocket connection.
- Parameters
-
| message | The message to send |
- Returns
- true if message was sent successfully, false otherwise
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.
Implements plotly::detail::WebsocketEndpointInterface.
◆ serve()
| auto plotly::detail::WebsocketServer::serve |
( |
std::string_view | address, |
|
|
int | port ) -> bool |
◆ serviceLoop()
| void plotly::detail::WebsocketServer::serviceLoop |
( |
| ) |
|
|
overrideprotectedvirtual |
Pure virtual method for the main service loop.
Derived classes must implement this method to provide specific WebSocket client or server behavior. This method runs in the service thread and should handle connection management and message reception.
Implements plotly::detail::WebsocketEndpointImpl.
◆ stop()
| void plotly::detail::WebsocketServer::stop |
( |
| ) |
|
|
overridevirtual |
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.
Implements plotly::detail::WebsocketEndpointInterface.
◆ waitConnection()
| auto plotly::detail::WebsocketServer::waitConnection |
( |
std::chrono::milliseconds | timeout | ) |
const -> bool |
|
overridevirtual |
Wait for a connection to be established.
- Parameters
-
| timeout | Maximum time to wait for connection |
- Returns
- true if connection was established within timeout, false otherwise
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.
Implements plotly::detail::WebsocketEndpointInterface.
◆ waitUntilNoClient()
| void plotly::detail::WebsocketServer::waitUntilNoClient |
( |
| ) |
const |
The documentation for this class was generated from the following files: