15#include <system_error>
52 virtual auto close(uint16_t code, std::string_view reason =
"") ->
void = 0;
58 [[nodiscard]]
virtual auto path() const -> std::string_view = 0;
87 std::string_view session_id,
89 std::string_view reason)>;
92 using text_callback_t = std::function<void(std::string_view,
const std::string&)>;
95 using binary_callback_t = std::function<void(std::string_view,
const std::vector<uint8_t>&)>;
Base interface for all network components.
Interface for a single client session on the server side.
Interface for WebSocket server components.
virtual auto start(uint16_t port) -> VoidResult=0
Starts the WebSocket server on the specified port.
std::function< void(std::string_view, const std::vector< uint8_t > &)> binary_callback_t
Callback type for binary messages (session_id, data)
std::function< void(std::string_view, std::error_code)> error_callback_t
Callback type for errors (session_id, error)
std::function< void(std::string_view, const std::string &)> text_callback_t
Callback type for text messages (session_id, message)
virtual auto stop() -> VoidResult=0
Stops the WebSocket server.
std::function< void( std::string_view session_id, uint16_t code, std::string_view reason)> disconnection_callback_t
Callback type for disconnections (with close code and reason)
std::function< void(std::shared_ptr< i_websocket_session >)> connection_callback_t
Callback type for new connections.
virtual auto connection_count() const -> size_t=0
Gets the number of active WebSocket connections.
Interface for a WebSocket session on the server side.
virtual auto send_binary(std::vector< uint8_t > &&data) -> VoidResult=0
Sends a binary message to the client.
virtual auto send_text(std::string &&message) -> VoidResult=0
Sends a text message to the client.
virtual auto close(uint16_t code, std::string_view reason="") -> void=0
Closes the WebSocket connection gracefully.
virtual auto path() const -> std::string_view=0
Gets the requested path from the handshake.
Base interface for all network components.
Session interface representing an active client-server connection.
Network-specific error and result type definitions.