|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Interface for WebSocket server components. More...
#include <i_websocket_server.h>


Public Types | |
| using | connection_callback_t = std::function<void(std::shared_ptr<i_websocket_session>)> |
| Callback type for new connections. | |
| using | disconnection_callback_t |
| Callback type for disconnections (with close code and reason) | |
| using | text_callback_t = std::function<void(std::string_view, const std::string&)> |
| Callback type for text messages (session_id, message) | |
| using | binary_callback_t = std::function<void(std::string_view, const std::vector<uint8_t>&)> |
| Callback type for binary messages (session_id, data) | |
| using | error_callback_t = std::function<void(std::string_view, std::error_code)> |
| Callback type for errors (session_id, error) | |
Public Member Functions | |
| virtual auto | start (uint16_t port) -> VoidResult=0 |
| Starts the WebSocket server on the specified port. | |
| virtual auto | stop () -> VoidResult=0 |
| Stops the WebSocket server. | |
| virtual auto | connection_count () const -> size_t=0 |
| Gets the number of active WebSocket connections. | |
| virtual auto | set_connection_callback (connection_callback_t callback) -> void=0 |
| Sets the callback for new connections. | |
| virtual auto | set_disconnection_callback (disconnection_callback_t callback) -> void=0 |
| Sets the callback for disconnections. | |
| virtual auto | set_text_callback (text_callback_t callback) -> void=0 |
| Sets the callback for text messages. | |
| virtual auto | set_binary_callback (binary_callback_t callback) -> void=0 |
| Sets the callback for binary messages. | |
| virtual auto | set_error_callback (error_callback_t callback) -> void=0 |
| Sets the callback for errors. | |
Public Member Functions inherited from kcenon::network::interfaces::i_network_component | |
| virtual | ~i_network_component ()=default |
| Virtual destructor for proper cleanup of derived classes. | |
| i_network_component (const i_network_component &)=delete | |
| i_network_component & | operator= (const i_network_component &)=delete |
| i_network_component (i_network_component &&)=delete | |
| i_network_component & | operator= (i_network_component &&)=delete |
Additional Inherited Members | |
Protected Member Functions inherited from kcenon::network::interfaces::i_network_component | |
| i_network_component ()=default | |
| Default constructor (only for derived classes) | |
| virtual auto | is_running () const -> bool=0 |
| Checks if the component is currently running. | |
| virtual auto | wait_for_stop () -> void=0 |
| Blocks until the component has stopped. | |
Interface for WebSocket server components.
This interface extends i_network_component with WebSocket server-specific operations such as handling text/binary messages and session management.
Definition at line 79 of file i_websocket_server.h.
| using kcenon::network::interfaces::i_websocket_server::binary_callback_t = std::function<void(std::string_view, const std::vector<uint8_t>&)> |
Callback type for binary messages (session_id, data)
Definition at line 95 of file i_websocket_server.h.
| using kcenon::network::interfaces::i_websocket_server::connection_callback_t = std::function<void(std::shared_ptr<i_websocket_session>)> |
Callback type for new connections.
Definition at line 83 of file i_websocket_server.h.
Callback type for disconnections (with close code and reason)
Definition at line 86 of file i_websocket_server.h.
| using kcenon::network::interfaces::i_websocket_server::error_callback_t = std::function<void(std::string_view, std::error_code)> |
Callback type for errors (session_id, error)
Definition at line 98 of file i_websocket_server.h.
| using kcenon::network::interfaces::i_websocket_server::text_callback_t = std::function<void(std::string_view, const std::string&)> |
Callback type for text messages (session_id, message)
Definition at line 92 of file i_websocket_server.h.
|
nodiscardpure virtual |
Gets the number of active WebSocket connections.
Implemented in kcenon::network::core::messaging_ws_server.
|
pure virtual |
Sets the callback for binary messages.
| callback | The callback function. |
Implemented in kcenon::network::core::messaging_ws_server.
|
pure virtual |
Sets the callback for new connections.
| callback | The callback function. |
Implemented in kcenon::network::core::messaging_ws_server.
|
pure virtual |
Sets the callback for disconnections.
| callback | The callback function. |
Implemented in kcenon::network::core::messaging_ws_server.
|
pure virtual |
Sets the callback for errors.
| callback | The callback function. |
Implemented in kcenon::network::core::messaging_ws_server.
|
pure virtual |
Sets the callback for text messages.
| callback | The callback function. |
Implemented in kcenon::network::core::messaging_ws_server.
|
nodiscardpure virtual |
Starts the WebSocket server on the specified port.
| port | The port number to listen on. |
Thread-safe. Only one start operation can succeed at a time.
Implemented in kcenon::network::core::messaging_ws_server.
|
nodiscardpure virtual |
Stops the WebSocket server.
Implemented in kcenon::network::core::messaging_ws_server.