restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler > Class Template Referencefinal

Context for handling websocket connections. More...

`#include <ws_connection.hpp>`

Inheritance diagram for restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >:

## Classes

class | one_shot_action_t
| A helper class for running exclusive action. Only a first action will run. More...

## Public Types

using | message_handler_t = WS_Message_Handler
using | timer_manager_t = typename Traits::timer_manager_t
using | timer_manager_handle_t = std::shared_ptr< timer_manager_t >
using | timer_guard_t = typename timer_manager_t::timer_guard_t
using | logger_t = typename Traits::logger_t
using | strand_t = typename Traits::strand_t
using | stream_socket_t = typename Traits::stream_socket_t
using | lifetime_monitor_t = typename connection_count_limit_types< Traits >::lifetime_monitor_t
using | ws_weak_handle_t = std::weak_ptr< ws_t >

## Public Member Functions

| ws_connection_t (const ws_connection_t &)=delete
| ws_connection_t (ws_connection_t &&)=delete
ws_connection_t & | operator= (const ws_connection_t &)=delete
ws_connection_t & | operator= (ws_connection_t &&)=delete
| ~ws_connection_t () override
virtual void | shutdown () override
| Shutdown websocket. More...
virtual void | kill () override
| Kill websocket. More...
void | init_read (ws_handle_t wsh) override
| Start reading ws-messages. More...
virtual void | write_data (write_group_t wg, bool is_close_frame) override
| Write pieces of outgoing data. More...
Public Member Functions inherited from restinio::websocket::basic::impl::ws_connection_base_t
| ws_connection_base_t (connection_id_t id)
virtual void | shutdown ()=0
| Shutdown websocket. More...
virtual void | kill ()=0
| Kill websocket. More...
virtual void | init_read (ws_handle_t wsh)=0
| Start reading ws-messages. More...
virtual void | write_data (write_group_t wg, bool is_close_frame)=0
| Write pieces of outgoing data. More...
Public Member Functions inherited from restinio::tcp_connection_ctx_base_t
| tcp_connection_ctx_base_t (connection_id_t id)
virtual | ~tcp_connection_ctx_base_t ()=default
connection_id_t | connection_id () const noexcept
| Get connection id. More...
virtual void | check_timeout (std::shared_ptr< tcp_connection_ctx_base_t > &self)=0
| Check timeouts for all activities. More...
Public Member Functions inherited from restinio::impl::executor_wrapper_t< Traits::strand_t >
| executor_wrapper_t (Init_Executor &&init_executor)
virtual | ~executor_wrapper_t ()=default
Traits::strand_t & | get_executor () noexcept
| An executor for callbacks on async operations. More...

## Private Types

enum class | write_state_t { write_enabled , write_disabled }
| Websocket output states. More...
enum class | read_state_t { read_any_frame , read_only_close_frame , read_nothing }
| Websocket input states. More...
using | executor_wrapper_base_t = restinio::impl::executor_wrapper_t< typename Traits::strand_t >
using | none_write_operation_t = ::restinio::impl::write_group_output_ctx_t::none_write_operation_t
using | trivial_write_operation_t = ::restinio::impl::write_group_output_ctx_t::trivial_write_operation_t
using | file_write_operation_t = ::restinio::impl::write_group_output_ctx_t::file_write_operation_t

## Private Member Functions

void | close_impl () noexcept
| Standard close routine. More...
void | start_waiting_close_frame_only ()
| Start waiting for close-frame. More...
void | graceful_close ()
| Close WebSocket connection in a graceful manner. More...
void | send_close_frame_to_peer (std::string payload)
| Send close frame to peer. More...
void | send_close_frame_to_peer (status_code_t code, std::string desc=std::string{})
| Send close frame to peer. More...
template<typename MSG_BUILDER >
void | trigger_error_and_close (status_code_t status, MSG_BUILDER msg_builder) noexcept
| Trigger an error. More...
void | start_read_header ()
| Start the process of reading ws messages from socket. More...
void | consume_header_from_socket ()
| Initiate read operation on socket to receive bytes for header. More...
void | handle_read_error (const char *desc, const asio_ns::error_code &ec)
| Handle read error (reading header or payload) More...
void | after_read_header (const asio_ns::error_code &ec, std::size_t length)
| Handle read operation result, when reading header. More...
void | consume_header_from_buffer (const char *data, std::size_t length)
| Parse header from internal buffer. More...
void | handle_parsed_header (const message_details_t &md)
| Handle parsed header. More...
void | handle_parsed_and_valid_header (const message_details_t &md)
| Handle parsed and valid header. More...
void | start_read_payload (char *payload_data, std::size_t length_remaining, bool do_validate_payload_and_call_msg_handler=true)
| Start reading message payload. More...
void | after_read_payload (char *payload_data, std::size_t length_remaining, const asio_ns::error_code &ec, std::size_t length, bool do_validate_payload_and_call_msg_handler=true)
| Handle read operation result, when reading payload. More...
void | call_message_handler (message_handle_t close_frame)
| Call user message handler with current message. More...
bool | validate_payload_part (char *payload_data, std::size_t length, std::size_t next_length_remaining)
| Validates a part of received payload. More...
void | handle_invalid_payload (validation_state_t validation_result)
| Handle payload errors. More...
void | call_handler_on_current_message ()
void | call_close_handler_if_necessary (status_code_t status)
void | write_data_impl (write_group_t wg, bool is_close_frame)
| Implementation of writing data performed on the asio_ns::io_context. More...
void | init_write_if_necessary ()
| Checks if there is something to write, and if so starts write operation. More...
void | init_write ()
| Initiate write operation. More...
void | handle_current_write_ctx ()
void | handle_trivial_write_operation (const trivial_write_operation_t &op)
void | finish_handling_current_write_ctx ()
| Do post write actions for current write group. More...
void | after_write (const asio_ns::error_code &ec)
| Handle write response finished. More...

## Private Attributes

restinio::impl::connection_settings_handle_t< Traits > | m_settings
| Common paramaters of a connection. More...
stream_socket_t | m_socket
| Connection. More...
lifetime_monitor_t | m_lifetime_monitor
| Monitor of the connection lifetime. More...
connection_input_t | m_input
| Input routine. More...
ws_protocol_validator_t | m_protocol_validator { true }
| Helper for validating protocol. More...
message_handler_t | m_msg_handler
| Websocket message handler provided by user. More...
logger_t & | m_logger
| Logger for operation. More...
restinio::impl::write_group_output_ctx_t | m_write_output_ctx
| Write to socket operation context. More...
ws_outgoing_data_t | m_outgoing_data
| Output buffers queue. More...
ws_weak_handle_t | m_websocket_weak_handle
| A waek handler for owning ws_t to use it when call message handler. More...
write_state_t | m_write_state = write_state_t::write_enabled
| A state of a websocket output. More...
read_state_t | m_read_state = read_state_t::read_nothing
| A state of a websocket input. More...
one_shot_action_t | m_close_frame_to_user
one_shot_action_t | m_close_frame_to_peer
one_shot_action_t | m_close_impl
std::chrono::steady_clock::time_point | m_write_operation_timeout_after
std::chrono::steady_clock::time_point | m_close_frame_from_peer_timeout_after
tcp_connection_ctx_weak_handle_t | m_prepared_weak_ctx
timer_guard_t | m_timer_guard
virtual void | check_timeout (tcp_connection_ctx_handle_t &self) override
void | check_timeout_impl ()
void | init_next_timeout_checking ()
| schedule next timeout checking. More...
void | guard_write_operation ()
| Start guard write operation if necessary. More...
void | guard_close_frame_from_peer_operation ()
static ws_connection_t & | cast_to_self (tcp_connection_ctx_base_t &base)
| Timers. More...

## Additional Inherited Members

Protected Member Functions inherited from restinio::tcp_connection_ctx_base_t
template<typename Derived >
std::shared_ptr< Derived > | shared_from_concrete ()
| Cast self to derived class. More...

## Detailed Description

template<typename Traits, typename WS_Message_Handler>
class restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >

Context for handling websocket connections.

Definition at line 122 of file ws_connection.hpp.

## Member Typedef Documentation

## executor_wrapper_base_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::executor_wrapper_base_t = restinio::impl::executor_wrapper_t< typename Traits::strand_t >

private

Definition at line 126 of file ws_connection.hpp.

## file_write_operation_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::file_write_operation_t = ::restinio::impl::write_group_output_ctx_t::file_write_operation_t

private

Definition at line 1103 of file ws_connection.hpp.

## lifetime_monitor_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::lifetime_monitor_t = typename connection_count_limit_types<Traits>::lifetime_monitor_t

Definition at line 137 of file ws_connection.hpp.

## logger_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::logger_t = typename Traits::logger_t

Definition at line 134 of file ws_connection.hpp.

## message_handler_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::message_handler_t = WS_Message_Handler

Definition at line 129 of file ws_connection.hpp.

## none_write_operation_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::none_write_operation_t = ::restinio::impl::write_group_output_ctx_t::none_write_operation_t

private

Definition at line 1101 of file ws_connection.hpp.

## strand_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::strand_t = typename Traits::strand_t

Definition at line 135 of file ws_connection.hpp.

## stream_socket_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::stream_socket_t = typename Traits::stream_socket_t

Definition at line 136 of file ws_connection.hpp.

## timer_guard_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::timer_guard_t = typename timer_manager_t::timer_guard_t

Definition at line 133 of file ws_connection.hpp.

## timer_manager_handle_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::timer_manager_handle_t = std::shared_ptr< timer_manager_t >

Definition at line 132 of file ws_connection.hpp.

## timer_manager_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::timer_manager_t = typename Traits::timer_manager_t

Definition at line 131 of file ws_connection.hpp.

## trivial_write_operation_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::trivial_write_operation_t = ::restinio::impl::write_group_output_ctx_t::trivial_write_operation_t

private

Definition at line 1102 of file ws_connection.hpp.

## ws_weak_handle_t

template<typename Traits , typename WS_Message_Handler >

using restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::ws_weak_handle_t = std::weak_ptr< ws_t >

Definition at line 140 of file ws_connection.hpp.

## Member Enumeration Documentation

## read_state_t

template<typename Traits , typename WS_Message_Handler >

enum class restinio::websocket::basic::impl::ws_connection_t::read_state_t

strong private

Websocket input states.

Enumerator
read_any_frame | Reads any type of frame and serve it to user.
read_only_close_frame | Reads only close frame: skip all frames until close-frame.
read_nothing | Do not read anything (before activation).

Definition at line 1393 of file ws_connection.hpp.

## write_state_t

template<typename Traits , typename WS_Message_Handler >

enum class restinio::websocket::basic::impl::ws_connection_t::write_state_t

strong private

Websocket output states.

Enumerator
write_enabled | Able to append outgoing data.
write_disabled | No more outgoing data can be added (e.g. close-frame was sent).

Definition at line 1381 of file ws_connection.hpp.

## Constructor & Destructor Documentation

## ws_connection_t() [1/2]

template<typename Traits , typename WS_Message_Handler >

restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::ws_connection_t | ( | const ws_connection_t< Traits, WS_Message_Handler > & |  | ) |

delete

## ws_connection_t() [2/2]

template<typename Traits , typename WS_Message_Handler >

restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::ws_connection_t | ( | ws_connection_t< Traits, WS_Message_Handler > && |  | ) |

delete

## ~ws_connection_t()

template<typename Traits , typename WS_Message_Handler >

restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::~ws_connection_t | ( |  | ) |

inline override

Definition at line 192 of file ws_connection.hpp.

## Member Function Documentation

## after_read_header()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::after_read_header | ( | const asio_ns::error_code & | ec,
|  | std::size_t | length
| ) |  |

inline private

Handle read operation result, when reading header.

Definition at line 562 of file ws_connection.hpp.

## after_read_payload()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::after_read_payload | ( | char * | payload_data,
|  | std::size_t | length_remaining,
|  | const asio_ns::error_code & | ec,
|  | std::size_t | length,
|  | bool | do_validate_payload_and_call_msg_handler = `true`
| ) |  |

inline private

Handle read operation result, when reading payload.

Definition at line 748 of file ws_connection.hpp.

## after_write()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::after_write | ( | const asio_ns::error_code & | ec | ) |

inline private

Handle write response finished.

Definition at line 1216 of file ws_connection.hpp.

## call_close_handler_if_necessary()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::call_close_handler_if_necessary | ( | status_code_t | status | ) |

inline private

Definition at line 1003 of file ws_connection.hpp.

## call_handler_on_current_message()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::call_handler_on_current_message | ( |  | ) |

inline private

Definition at line 935 of file ws_connection.hpp.

## call_message_handler()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::call_message_handler | ( | message_handle_t | close_frame | ) |

inline private

Call user message handler with current message.

Definition at line 816 of file ws_connection.hpp.

## cast_to_self()

template<typename Traits , typename WS_Message_Handler >

static ws_connection_t & restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::cast_to_self | ( | tcp_connection_ctx_base_t & | base | ) |

inline static private

Timers.

Definition at line 1265 of file ws_connection.hpp.

## check_timeout()

template<typename Traits , typename WS_Message_Handler >

virtual void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::check_timeout | ( | tcp_connection_ctx_handle_t & | self | ) |

inline override private virtual

Definition at line 1271 of file ws_connection.hpp.

## check_timeout_impl()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::check_timeout_impl | ( |  | ) |

inline private

Definition at line 1307 of file ws_connection.hpp.

## close_impl()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::close_impl | ( |  | ) |

inline private noexcept

Standard close routine.

Note
  This method is noexcept since v.0.6.0.

Definition at line 371 of file ws_connection.hpp.

## consume_header_from_buffer()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::consume_header_from_buffer | ( | const char * | data,
|  | std::size_t | length
| ) |  |

inline private

Parse header from internal buffer.

Definition at line 586 of file ws_connection.hpp.

## consume_header_from_socket()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::consume_header_from_socket | ( |  | ) |

inline private

Initiate read operation on socket to receive bytes for header.

Definition at line 510 of file ws_connection.hpp.

## finish_handling_current_write_ctx()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::finish_handling_current_write_ctx | ( |  | ) |

inline private

Do post write actions for current write group.

Definition at line 1197 of file ws_connection.hpp.

## graceful_close()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::graceful_close | ( |  | ) |

inline private

Close WebSocket connection in a graceful manner.

Definition at line 413 of file ws_connection.hpp.

## guard_close_frame_from_peer_operation()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::guard_close_frame_from_peer_operation | ( |  | ) |

inline private

Definition at line 1352 of file ws_connection.hpp.

## guard_write_operation()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::guard_write_operation | ( |  | ) |

inline private

Start guard write operation if necessary.

Definition at line 1345 of file ws_connection.hpp.

## handle_current_write_ctx()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::handle_current_write_ctx | ( |  | ) |

inline private

Definition at line 1106 of file ws_connection.hpp.

## handle_invalid_payload()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::handle_invalid_payload | ( | validation_state_t | validation_result | ) |

inline private

Handle payload errors.

Definition at line 883 of file ws_connection.hpp.

## handle_parsed_and_valid_header()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::handle_parsed_and_valid_header | ( | const message_details_t & | md | ) |

inline private

Handle parsed and valid header.

Definition at line 651 of file ws_connection.hpp.

## handle_parsed_header()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::handle_parsed_header | ( | const message_details_t & | md | ) |

inline private

Handle parsed header.

Definition at line 605 of file ws_connection.hpp.

## handle_read_error()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::handle_read_error | ( | const char * | desc,
|  | const asio_ns::error_code & | ec
| ) |  |

inline private

Handle read error (reading header or payload)

Definition at line 546 of file ws_connection.hpp.

## handle_trivial_write_operation()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::handle_trivial_write_operation | ( | const trivial_write_operation_t & | op | ) |

inline private

Definition at line 1140 of file ws_connection.hpp.

## init_next_timeout_checking()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::init_next_timeout_checking | ( |  | ) |

inline private

schedule next timeout checking.

Definition at line 1338 of file ws_connection.hpp.

## init_read()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::init_read | ( | ws_handle_t | wsh | ) |

inline override virtual

Start reading ws-messages.

Implements restinio::websocket::basic::impl::ws_connection_base_t.

Definition at line 284 of file ws_connection.hpp.

## init_write()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::init_write | ( |  | ) |

inline private

Initiate write operation.

Definition at line 1075 of file ws_connection.hpp.

## init_write_if_necessary()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::init_write_if_necessary | ( |  | ) |

inline private

Checks if there is something to write, and if so starts write operation.

Definition at line 1065 of file ws_connection.hpp.

## kill()

template<typename Traits , typename WS_Message_Handler >

virtual void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::kill | ( |  | ) |

inline override virtual

Kill websocket.

Implements restinio::websocket::basic::impl::ws_connection_base_t.

Definition at line 245 of file ws_connection.hpp.

## operator=() [1/2]

template<typename Traits , typename WS_Message_Handler >

ws_connection_t & restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::operator= | ( | const ws_connection_t< Traits, WS_Message_Handler > & |  | ) |

delete

## operator=() [2/2]

template<typename Traits , typename WS_Message_Handler >

ws_connection_t & restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::operator= | ( | ws_connection_t< Traits, WS_Message_Handler > && |  | ) |

delete

## send_close_frame_to_peer() [1/2]

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::send_close_frame_to_peer | ( | status_code_t | code,
|  | std::string | desc = `std::string{}`
| ) |  |

inline private

Send close frame to peer.

Definition at line 446 of file ws_connection.hpp.

## send_close_frame_to_peer() [2/2]

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::send_close_frame_to_peer | ( | std::string | payload | ) |

inline private

Send close frame to peer.

Definition at line 424 of file ws_connection.hpp.

## shutdown()

template<typename Traits , typename WS_Message_Handler >

virtual void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::shutdown | ( |  | ) |

inline override virtual

Shutdown websocket.

Implements restinio::websocket::basic::impl::ws_connection_base_t.

Definition at line 209 of file ws_connection.hpp.

## start_read_header()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::start_read_header | ( |  | ) |

inline private

Start the process of reading ws messages from socket.

Definition at line 485 of file ws_connection.hpp.

## start_read_payload()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::start_read_payload | ( | char * | payload_data,
|  | std::size_t | length_remaining,
|  | bool | do_validate_payload_and_call_msg_handler = `true`
| ) |  |

inline private

Start reading message payload.

Parameters

  payload_data | A pointer to the remainder of unfetched payload.
  length_remaining | The size of the remainder of unfetched payload.
  do_validate_payload_and_call_msg_handler | Validate payload and call handler.

Definition at line 703 of file ws_connection.hpp.

## start_waiting_close_frame_only()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::start_waiting_close_frame_only | ( |  | ) |

inline private

Start waiting for close-frame.

Definition at line 405 of file ws_connection.hpp.

## trigger_error_and_close()

template<typename Traits , typename WS_Message_Handler >
template<typename MSG_BUILDER >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::trigger_error_and_close | ( | status_code_t | status,
|  | MSG_BUILDER | msg_builder
| ) |  |

inline private noexcept

Trigger an error.

Writes error message to log, closes socket, and sends close frame to user if necessary.

Note
  This method is noexcept since v.0.6.0

Definition at line 464 of file ws_connection.hpp.

## validate_payload_part()

template<typename Traits , typename WS_Message_Handler >

bool restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::validate_payload_part | ( | char * | payload_data,
|  | std::size_t | length,
|  | std::size_t | next_length_remaining
| ) |  |

inline private

Validates a part of received payload.

Definition at line 840 of file ws_connection.hpp.

## write_data()

template<typename Traits , typename WS_Message_Handler >

virtual void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::write_data | ( | write_group_t | wg,
|  | bool | is_close_frame
| ) |  |

inline override virtual

Write pieces of outgoing data.

Run write message on io_context loop if possible.

Implements restinio::websocket::basic::impl::ws_connection_base_t.

Definition at line 321 of file ws_connection.hpp.

## write_data_impl()

template<typename Traits , typename WS_Message_Handler >

void restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::write_data_impl | ( | write_group_t | wg,
|  | bool | is_close_frame
| ) |  |

inline private

Implementation of writing data performed on the asio_ns::io_context.

Definition at line 1017 of file ws_connection.hpp.

## Member Data Documentation

## m_close_frame_from_peer_timeout_after

template<typename Traits , typename WS_Message_Handler >

std::chrono::steady_clock::time_point restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_close_frame_from_peer_timeout_after

private

Initial value:
=
std::chrono::steady_clock::time_point::max()

Definition at line 1301 of file ws_connection.hpp.

## m_close_frame_to_peer

template<typename Traits , typename WS_Message_Handler >

one_shot_action_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_close_frame_to_peer

private

Definition at line 1434 of file ws_connection.hpp.

## m_close_frame_to_user

template<typename Traits , typename WS_Message_Handler >

one_shot_action_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_close_frame_to_user

private

Definition at line 1433 of file ws_connection.hpp.

## m_close_impl

template<typename Traits , typename WS_Message_Handler >

one_shot_action_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_close_impl

private

Definition at line 1435 of file ws_connection.hpp.

## m_input

template<typename Traits , typename WS_Message_Handler >

connection_input_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_input

private

Input routine.

Definition at line 1360 of file ws_connection.hpp.

## m_lifetime_monitor

template<typename Traits , typename WS_Message_Handler >

lifetime_monitor_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_lifetime_monitor

private

Monitor of the connection lifetime.

Since
  v.0.6.12

Definition at line 1260 of file ws_connection.hpp.

## m_logger

template<typename Traits , typename WS_Message_Handler >

logger_t& restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_logger

private

Logger for operation.

Definition at line 1369 of file ws_connection.hpp.

## m_msg_handler

template<typename Traits , typename WS_Message_Handler >

message_handler_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_msg_handler

private

Websocket message handler provided by user.

Definition at line 1366 of file ws_connection.hpp.

## m_outgoing_data

template<typename Traits , typename WS_Message_Handler >

ws_outgoing_data_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_outgoing_data

private

Output buffers queue.

Definition at line 1375 of file ws_connection.hpp.

## m_prepared_weak_ctx

template<typename Traits , typename WS_Message_Handler >

tcp_connection_ctx_weak_handle_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_prepared_weak_ctx

private

Definition at line 1303 of file ws_connection.hpp.

## m_protocol_validator

template<typename Traits , typename WS_Message_Handler >

ws_protocol_validator_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_protocol_validator { true }

private

Helper for validating protocol.

Definition at line 1363 of file ws_connection.hpp.

## m_read_state

template<typename Traits , typename WS_Message_Handler >

read_state_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_read_state = read_state_t::read_nothing

private

A state of a websocket input.

Definition at line 1404 of file ws_connection.hpp.

## m_settings

template<typename Traits , typename WS_Message_Handler >

restinio::impl::connection_settings_handle_t< Traits > restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_settings

private

Common paramaters of a connection.

Definition at line 1250 of file ws_connection.hpp.

## m_socket

template<typename Traits , typename WS_Message_Handler >

stream_socket_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_socket

private

Connection.

Definition at line 1253 of file ws_connection.hpp.

## m_timer_guard

template<typename Traits , typename WS_Message_Handler >

timer_guard_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_timer_guard

private

Definition at line 1304 of file ws_connection.hpp.

## m_websocket_weak_handle

template<typename Traits , typename WS_Message_Handler >

ws_weak_handle_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_websocket_weak_handle

private

A waek handler for owning ws_t to use it when call message handler.

Definition at line 1378 of file ws_connection.hpp.

## m_write_operation_timeout_after

template<typename Traits , typename WS_Message_Handler >

std::chrono::steady_clock::time_point restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_write_operation_timeout_after

private

Definition at line 1300 of file ws_connection.hpp.

## m_write_output_ctx

template<typename Traits , typename WS_Message_Handler >

restinio::impl::write_group_output_ctx_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_write_output_ctx

private

Write to socket operation context.

Definition at line 1372 of file ws_connection.hpp.

## m_write_state

template<typename Traits , typename WS_Message_Handler >

write_state_t restinio::websocket::basic::impl::ws_connection_t< Traits, WS_Message_Handler >::m_write_state = write_state_t::write_enabled

private

A state of a websocket output.

Definition at line 1390 of file ws_connection.hpp.

The documentation for this class was generated from the following file:

- restinio/websocket/impl/ws_connection.hpp