39 :
public std::enable_shared_from_this< ws_t >
49 ws.m_ws_connection_handle->init_read(
ws.shared_from_this() );
127 final_flag, opcode, asio_ns::buffer_size( payload.
buf() ) };
132 bufs.emplace_back( std::move( payload ) );
143 opcode_t::connection_close_frame == opcode;
161 throw exception_t{
"ws doesn't support sendfile" };
166 throw exception_t{
"websocket is not available" };
231 fmt::format(
"{} field is mandatory for upgrade response",
244 throw exception_t{
"no connection for upgrade: already moved" };
246 auto &
con =
dynamic_cast< connection_t &
>( *conn_ptr );
252 std::make_shared< ws_connection_t >(
279 std::make_shared< ws_t >( std::move(
ws_connection ),
req.remote_endpoint() );
302 http_field::sec_websocket_accept,
326 http_field::sec_websocket_accept,
330 http_field::sec_websocket_protocol,
352 req.header().get_field( restinio::http_field::sec_websocket_key ) +
362 http_field::sec_websocket_accept,
Exception class for all exceptions thrown by RESTinio.
Context for handling http connections.
Websocket message class with more detailed protocol information.
Context for handling websocket connections.
final_frame_flag_t final_flag() const noexcept
Get final flag.
opcode_t opcode() const noexcept
void send_message(message_t msg, write_status_cb_t wscb=write_status_cb_t{})
ws_t(impl::ws_connection_handle_t ws_connection_handle, endpoint_t remote_endpoint)
ws_t & operator=(const ws_t &)=delete
ws_t(const ws_t &)=delete
impl::ws_connection_handle_t m_ws_connection_handle
connection_id_t connection_id() const
Get connection id.
void shutdown()
Shutdown websocket: wait for all outgoing data to be sent, and close connection.
void kill()
Kill websocket: close underlying tcp socket. Do not tolerate unsent outgoing data.
friend void activate(ws_t &ws)
Activate websocket: start receiving messages.
const endpoint_t & remote_endpoint() const noexcept
Get the remote endpoint of the underlying connection.
const endpoint_t m_remote_endpoint
Remote endpoint for this ws-connection.
void send_message(final_frame_flag_t final_flag, opcode_t opcode, writable_item_t payload, write_status_cb_t wscb=write_status_cb_t{})
Send_websocket message.
Class for storing the buffers used for streaming body (request/response).
asio_ns::const_buffer buf() const
Create a buf reference object used by ASIO.
writable_item_type_t write_type() const noexcept
Get a type of a stored buffer object.
Group of writable items transported to the context of underlying connection as one solid piece.
void after_write_notificator(write_status_cb_t notificator) noexcept
Set after write notificator.
connection_handle_t & access_req_connection(generic_request_t< Extra_Data > &) noexcept
std::string create_header_string(const http_response_header_t &h, content_length_field_presence_t content_length_field_presence=content_length_field_presence_t::add_content_length, std::size_t buffer_size=0)
Creates a string for http response header.
std::string encode(string_view_t str)
std::string to_string(const digest_t &what)
digest_t make_digest(const std::uint8_t *what, std::size_t length)
raw_data_t write_message_details(const message_details_t &message)
Serialize websocket message details into bytes buffer.
std::shared_ptr< ws_connection_base_t > ws_connection_handle_t
Alias for WebSocket connection handle.
activation_t
Flags for websocket activation policies.
@ immediate
Activate immediately after upgrade operation.
@ delayed
User will initiate activation later.
final_frame_flag_t
WS frame (message) "final"/"not final" flag.
std::shared_ptr< ws_t > ws_handle_t
Alias for ws_t handle.
std::vector< writable_item_t > writable_items_container_t
run_on_this_thread_settings_t< Traits > on_this_thread()
A special marker for the case when http_server must be run on the context of the current thread.
@ trivial_write_operation
Item is a buffer and must be written trivially.
const char * field_to_string(http_field_t f) noexcept
Helper sunction to get method string name.
http_status_line_t status_switching_protocols()
std::function< void(const asio_ns::error_code &ec) > write_status_cb_t
An alias for a callback to be invoked after the write operation of a particular group of "buffers".
asio_ns::ip::tcp::endpoint endpoint_t
An alias for endpoint type from Asio.
std::uint64_t connection_id_t
Type for ID of connection.