Network System 0.1.1
High-performance modular networking library for scalable client-server applications
Loading...
Searching...
No Matches
kcenon::network::concepts::MessageSocket Concept Reference

Concept for message-oriented sockets (WebSocket). More...

#include <socket_concepts.h>

Concept definition

template<typename T>
T& socket, std::string text, std::vector<uint8_t> binary,
std::function<void(std::error_code, std::size_t)> handler) {
{ socket.is_open() } -> std::convertible_to<bool>;
{ socket.start_read() } -> std::same_as<void>;
{
socket.set_error_callback(std::function<void(std::error_code)>{})
} -> std::same_as<void>;
}
Concept for message-oriented sockets (WebSocket).

Detailed Description

Concept for message-oriented sockets (WebSocket).

Message sockets provide framed, message-based communication. They distinguish between text and binary messages.

Types satisfying this concept: websocket_socket

Example usage:

template<MessageSocket S>
void send_json(S& socket, const std::string& json) {
socket.async_send_text(std::string{json}, [](std::error_code ec, size_t n) {
if (ec) {
// handle error
}
});
}

Definition at line 221 of file socket_concepts.h.