ゴミ箱
|
#include <stream.hpp>
Classes | |
class | accept_op |
class | close_op |
class | handshake_op |
class | ping_op |
class | read_op |
class | read_some_op |
class | response_op |
class | write_some_op |
Public Types | |
using | next_layer_type = typename std::remove_reference< NextLayer >::type |
The type of the next layer. More... | |
using | lowest_layer_type = typename get_lowest_layer< next_layer_type >::type |
The type of the lowest layer. More... | |
Public Member Functions | |
~stream ()=default | |
stream (stream &&)=default | |
stream & | operator= (stream &&)=default |
template<class... Args> | |
stream (Args &&...args) | |
boost::asio::io_service & | get_io_service () |
next_layer_type & | next_layer () |
next_layer_type const & | next_layer () const |
lowest_layer_type & | lowest_layer () |
lowest_layer_type const & | lowest_layer () const |
bool | is_open () const |
bool | got_binary () const |
bool | got_text () const |
bool | is_message_done () const |
Returns true if the last completed read finished the current message. More... | |
close_reason const & | reason () const |
std::size_t | read_size_hint (std::size_t initial_size=+tcp_frame_size) const |
template<class DynamicBuffer , class = typename std::enable_if< ! std::is_integral<DynamicBuffer>::value>::type> | |
std::size_t | read_size_hint (DynamicBuffer &buffer) const |
void | set_option (permessage_deflate const &o) |
Set the permessage-deflate extension options. More... | |
void | get_option (permessage_deflate &o) |
Get the permessage-deflate extension options. More... | |
void | auto_fragment (bool value) |
bool | auto_fragment () const |
Returns true if the automatic fragmentation option is set. More... | |
void | binary (bool value) |
bool | binary () const |
Returns true if the binary message option is set. More... | |
template<class Callback > | |
void | control_callback (Callback &cb) |
void | control_callback () |
void | read_message_max (std::size_t amount) |
std::size_t | read_message_max () const |
Returns the maximum incoming message size setting. More... | |
void | write_buffer_size (std::size_t amount) |
std::size_t | write_buffer_size () const |
Returns the size of the write buffer. More... | |
void | text (bool value) |
bool | text () const |
Returns true if the text message option is set. More... | |
void | handshake (string_view host, string_view target) |
void | handshake (response_type &res, string_view host, string_view target) |
template<class RequestDecorator > | |
void | handshake_ex (string_view host, string_view target, RequestDecorator const &decorator) |
template<class RequestDecorator > | |
void | handshake_ex (response_type &res, string_view host, string_view target, RequestDecorator const &decorator) |
void | handshake (string_view host, string_view target, error_code &ec) |
void | handshake (response_type &res, string_view host, string_view target, error_code &ec) |
template<class RequestDecorator > | |
void | handshake_ex (string_view host, string_view target, RequestDecorator const &decorator, error_code &ec) |
template<class RequestDecorator > | |
void | handshake_ex (response_type &res, string_view host, string_view target, RequestDecorator const &decorator, error_code &ec) |
template<class HandshakeHandler > | |
async_return_type< HandshakeHandler, void(error_code)> | async_handshake (string_view host, string_view target, HandshakeHandler &&handler) |
template<class HandshakeHandler > | |
async_return_type< HandshakeHandler, void(error_code)> | async_handshake (response_type &res, string_view host, string_view target, HandshakeHandler &&handler) |
template<class RequestDecorator , class HandshakeHandler > | |
async_return_type< HandshakeHandler, void(error_code)> | async_handshake_ex (string_view host, string_view target, RequestDecorator const &decorator, HandshakeHandler &&handler) |
template<class RequestDecorator , class HandshakeHandler > | |
async_return_type< HandshakeHandler, void(error_code)> | async_handshake_ex (response_type &res, string_view host, string_view target, RequestDecorator const &decorator, HandshakeHandler &&handler) |
void | accept () |
template<class ResponseDecorator > | |
void | accept_ex (ResponseDecorator const &decorator) |
void | accept (error_code &ec) |
template<class ResponseDecorator > | |
void | accept_ex (ResponseDecorator const &decorator, error_code &ec) |
template<class ConstBufferSequence > | |
std::enable_if<!http::detail::is_header< ConstBufferSequence >::value >::type | accept (ConstBufferSequence const &buffers) |
template<class ConstBufferSequence , class ResponseDecorator > | |
std::enable_if<!http::detail::is_header< ConstBufferSequence >::value >::type | accept_ex (ConstBufferSequence const &buffers, ResponseDecorator const &decorator) |
template<class ConstBufferSequence > | |
std::enable_if<!http::detail::is_header< ConstBufferSequence >::value >::type | accept (ConstBufferSequence const &buffers, error_code &ec) |
template<class ConstBufferSequence , class ResponseDecorator > | |
std::enable_if<!http::detail::is_header< ConstBufferSequence >::value >::type | accept_ex (ConstBufferSequence const &buffers, ResponseDecorator const &decorator, error_code &ec) |
template<class Body , class Allocator > | |
void | accept (http::request< Body, http::basic_fields< Allocator >> const &req) |
template<class Body , class Allocator , class ResponseDecorator > | |
void | accept_ex (http::request< Body, http::basic_fields< Allocator >> const &req, ResponseDecorator const &decorator) |
template<class Body , class Allocator > | |
void | accept (http::request< Body, http::basic_fields< Allocator >> const &req, error_code &ec) |
template<class Body , class Allocator , class ResponseDecorator > | |
void | accept_ex (http::request< Body, http::basic_fields< Allocator >> const &req, ResponseDecorator const &decorator, error_code &ec) |
template<class AcceptHandler > | |
async_return_type< AcceptHandler, void(error_code)> | async_accept (AcceptHandler &&handler) |
template<class ResponseDecorator , class AcceptHandler > | |
async_return_type< AcceptHandler, void(error_code)> | async_accept_ex (ResponseDecorator const &decorator, AcceptHandler &&handler) |
template<class ConstBufferSequence , class AcceptHandler > | |
std::enable_if< !http::detail::is_header< ConstBufferSequence >::value, async_return_type< AcceptHandler, void(error_code)> >::type | async_accept (ConstBufferSequence const &buffers, AcceptHandler &&handler) |
template<class ConstBufferSequence , class ResponseDecorator , class AcceptHandler > | |
std::enable_if< !http::detail::is_header< ConstBufferSequence >::value, async_return_type< AcceptHandler, void(error_code)> >::type | async_accept_ex (ConstBufferSequence const &buffers, ResponseDecorator const &decorator, AcceptHandler &&handler) |
template<class Body , class Allocator , class AcceptHandler > | |
async_return_type< AcceptHandler, void(error_code)> | async_accept (http::request< Body, http::basic_fields< Allocator >> const &req, AcceptHandler &&handler) |
template<class Body , class Allocator , class ResponseDecorator , class AcceptHandler > | |
async_return_type< AcceptHandler, void(error_code)> | async_accept_ex (http::request< Body, http::basic_fields< Allocator >> const &req, ResponseDecorator const &decorator, AcceptHandler &&handler) |
void | close (close_reason const &cr) |
void | close (close_reason const &cr, error_code &ec) |
template<class CloseHandler > | |
async_return_type< CloseHandler, void(error_code)> | async_close (close_reason const &cr, CloseHandler &&handler) |
void | ping (ping_data const &payload) |
void | ping (ping_data const &payload, error_code &ec) |
template<class WriteHandler > | |
async_return_type< WriteHandler, void(error_code)> | async_ping (ping_data const &payload, WriteHandler &&handler) |
void | pong (ping_data const &payload) |
void | pong (ping_data const &payload, error_code &ec) |
template<class WriteHandler > | |
async_return_type< WriteHandler, void(error_code)> | async_pong (ping_data const &payload, WriteHandler &&handler) |
template<class DynamicBuffer > | |
std::size_t | read (DynamicBuffer &buffer) |
template<class DynamicBuffer > | |
std::size_t | read (DynamicBuffer &buffer, error_code &ec) |
template<class DynamicBuffer , class ReadHandler > | |
async_return_type< ReadHandler, void(error_code, std::size_t)> | async_read (DynamicBuffer &buffer, ReadHandler &&handler) |
template<class DynamicBuffer > | |
std::size_t | read_some (DynamicBuffer &buffer, std::size_t limit) |
template<class DynamicBuffer > | |
std::size_t | read_some (DynamicBuffer &buffer, std::size_t limit, error_code &ec) |
template<class DynamicBuffer , class ReadHandler > | |
async_return_type< ReadHandler, void(error_code, std::size_t)> | async_read_some (DynamicBuffer &buffer, std::size_t limit, ReadHandler &&handler) |
template<class MutableBufferSequence > | |
std::size_t | read_some (MutableBufferSequence const &buffers) |
template<class MutableBufferSequence > | |
std::size_t | read_some (MutableBufferSequence const &buffers, error_code &ec) |
template<class MutableBufferSequence , class ReadHandler > | |
async_return_type< ReadHandler, void(error_code, std::size_t)> | async_read_some (MutableBufferSequence const &buffers, ReadHandler &&handler) |
template<class ConstBufferSequence > | |
std::size_t | write (ConstBufferSequence const &buffers) |
template<class ConstBufferSequence > | |
std::size_t | write (ConstBufferSequence const &buffers, error_code &ec) |
template<class ConstBufferSequence , class WriteHandler > | |
async_return_type< WriteHandler, void(error_code, std::size_t)> | async_write (ConstBufferSequence const &buffers, WriteHandler &&handler) |
template<class ConstBufferSequence > | |
std::size_t | write_some (bool fin, ConstBufferSequence const &buffers) |
template<class ConstBufferSequence > | |
std::size_t | write_some (bool fin, ConstBufferSequence const &buffers, error_code &ec) |
template<class ConstBufferSequence , class WriteHandler > | |
async_return_type< WriteHandler, void(error_code, std::size_t)> | async_write_some (bool fin, ConstBufferSequence const &buffers, WriteHandler &&handler) |
Friends | |
class | close_test |
class | frame_test |
class | ping_test |
class | read_test |
class | stream_test |
class | write_test |
Provides message-oriented functionality using WebSocket.
The stream class template provides asynchronous and blocking message-oriented functionality necessary for clients and servers to utilize the WebSocket protocol.
For asynchronous operations, the application must ensure that they are are all performed within the same implicit or explicit strand.
To use the stream template with an ip::tcp::socket
, you would write:
Alternatively, you can write:
NextLayer | The type representing the next layer, to which data will be read and written during operations. For synchronous operations, the type must support the SyncStream concept. For asynchronous operations, the type must support the AsyncStream concept. |
using boost::beast::websocket::stream< NextLayer >::lowest_layer_type = typename get_lowest_layer<next_layer_type>::type |
The type of the lowest layer.
using boost::beast::websocket::stream< NextLayer >::next_layer_type = typename std::remove_reference<NextLayer>::type |
The type of the next layer.
|
default |
Destructor
Destroys the stream and all associated resources.
|
default |
Constructor
If NextLayer
is move constructible, this function will move-construct a new stream from the existing stream.
|
explicit |
Constructor
This constructor creates a websocket stream and initializes the next layer object.
Any | exceptions thrown by the NextLayer constructor. |
args | The arguments to be passed to initialize the next layer object. The arguments are forwarded to the next layer's constructor. |
void boost::beast::websocket::stream< NextLayer >::accept | ( | ) |
Read and respond to a WebSocket HTTP Upgrade request.
This function is used to synchronously read an HTTP WebSocket Upgrade request and send the HTTP response. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.
The implementation uses fixed size internal storage to receive the request. If the request is too large, the error error::buffer_overflow will be indicated. Applications that wish to receive larger requests should first read the request using their own buffer and a suitable overload of http::read or http::async_read, then call accept or async_accept with the request.
system_error | Thrown on failure. |
void boost::beast::websocket::stream< NextLayer >::accept | ( | error_code & | ec | ) |
Read and respond to a WebSocket HTTP Upgrade request.
This function is used to synchronously read an HTTP WebSocket Upgrade request and send the HTTP response. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.
The implementation uses fixed size internal storage to receive the request. If the request is too large, the error error::buffer_overflow will be indicated. Applications that wish to receive larger requests should first read the request using their own buffer and a suitable overload of http::read or http::async_read, then call accept or async_accept with the request.
ec | Set to indicate what error occurred, if any. |
std::enable_if<!http::detail::is_header< ConstBufferSequence >::value >::type boost::beast::websocket::stream< NextLayer >::accept | ( | ConstBufferSequence const & | buffers | ) |
Read and respond to a WebSocket HTTP Upgrade request.
This function is used to synchronously read an HTTP WebSocket Upgrade request and send the HTTP response. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.
The implementation uses fixed size internal storage to receive the request. If the request is too large, the error error::buffer_overflow will be indicated. Applications that wish to receive larger requests should first read the request using their own buffer and a suitable overload of http::read or http::async_read, then call accept or async_accept with the request.
buffers | Caller provided data that has already been received on the stream. The implementation will copy the caller provided data before the function returns. |
system_error | Thrown on failure. |
std::enable_if<!http::detail::is_header< ConstBufferSequence >::value >::type boost::beast::websocket::stream< NextLayer >::accept | ( | ConstBufferSequence const & | buffers, |
error_code & | ec | ||
) |
Read and respond to a WebSocket HTTP Upgrade request.
This function is used to synchronously read an HTTP WebSocket Upgrade request and send the HTTP response. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.
The implementation uses fixed size internal storage to receive the request. If the request is too large, the error error::buffer_overflow will be indicated. Applications that wish to receive larger requests should first read the request using their own buffer and a suitable overload of http::read or http::async_read, then call accept or async_accept with the request.
buffers | Caller provided data that has already been received on the stream. The implementation will copy the caller provided data before the function returns. |
ec | Set to indicate what error occurred, if any. |
void boost::beast::websocket::stream< NextLayer >::accept | ( | http::request< Body, http::basic_fields< Allocator >> const & | req | ) |
Respond to a WebSocket HTTP Upgrade request
This function is used to synchronously send the HTTP response to an HTTP request possibly containing a WebSocket Upgrade. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.
req | An object containing the HTTP Upgrade request. Ownership is not transferred, the implementation will not access this object from other threads. |
system_error | Thrown on failure. |
void boost::beast::websocket::stream< NextLayer >::accept | ( | http::request< Body, http::basic_fields< Allocator >> const & | req, |
error_code & | ec | ||
) |
Respond to a WebSocket HTTP Upgrade request
This function is used to synchronously send the HTTP response to an HTTP request possibly containing a WebSocket Upgrade. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.
req | An object containing the HTTP Upgrade request. Ownership is not transferred, the implementation will not access this object from other threads. |
ec | Set to indicate what error occurred, if any. |
void boost::beast::websocket::stream< NextLayer >::accept_ex | ( | ResponseDecorator const & | decorator | ) |
Read and respond to a WebSocket HTTP Upgrade request.
This function is used to synchronously read an HTTP WebSocket Upgrade request and send the HTTP response. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.
The implementation uses fixed size internal storage to receive the request. If the request is too large, the error error::buffer_overflow will be indicated. Applications that wish to receive larger requests should first read the request using their own buffer and a suitable overload of http::read or http::async_read, then call accept or async_accept with the request.
decorator | A function object which will be called to modify the HTTP response object delivered by the implementation. This could be used to set the Server field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
system_error | Thrown on failure. |
void boost::beast::websocket::stream< NextLayer >::accept_ex | ( | ResponseDecorator const & | decorator, |
error_code & | ec | ||
) |
Read and respond to a WebSocket HTTP Upgrade request.
This function is used to synchronously read an HTTP WebSocket Upgrade request and send the HTTP response. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.
The implementation uses fixed size internal storage to receive the request. If the request is too large, the error error::buffer_overflow will be indicated. Applications that wish to receive larger requests should first read the request using their own buffer and a suitable overload of http::read or http::async_read, then call accept or async_accept with the request.
decorator | A function object which will be called to modify the HTTP response object delivered by the implementation. This could be used to set the Server field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
ec | Set to indicate what error occurred, if any. |
std::enable_if<!http::detail::is_header< ConstBufferSequence >::value >::type boost::beast::websocket::stream< NextLayer >::accept_ex | ( | ConstBufferSequence const & | buffers, |
ResponseDecorator const & | decorator | ||
) |
Read and respond to a WebSocket HTTP Upgrade request.
This function is used to synchronously read an HTTP WebSocket Upgrade request and send the HTTP response. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.
The implementation uses fixed size internal storage to receive the request. If the request is too large, the error error::buffer_overflow will be indicated. Applications that wish to receive larger requests should first read the request using their own buffer and a suitable overload of http::read or http::async_read, then call accept or async_accept with the request.
buffers | Caller provided data that has already been received on the stream. The implementation will copy the caller provided data before the function returns. |
decorator | A function object which will be called to modify the HTTP response object delivered by the implementation. This could be used to set the Server field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
system_error | Thrown on failure. |
std::enable_if<!http::detail::is_header< ConstBufferSequence >::value >::type boost::beast::websocket::stream< NextLayer >::accept_ex | ( | ConstBufferSequence const & | buffers, |
ResponseDecorator const & | decorator, | ||
error_code & | ec | ||
) |
Read and respond to a WebSocket HTTP Upgrade request.
This function is used to synchronously read an HTTP WebSocket Upgrade request and send the HTTP response. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.
The implementation uses fixed size internal storage to receive the request. If the request is too large, the error error::buffer_overflow will be indicated. Applications that wish to receive larger requests should first read the request using their own buffer and a suitable overload of http::read or http::async_read, then call accept or async_accept with the request.
buffers | Caller provided data that has already been received on the stream. The implementation will copy the caller provided data before the function returns. |
decorator | A function object which will be called to modify the HTTP response object delivered by the implementation. This could be used to set the Server field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
ec | Set to indicate what error occurred, if any. |
void boost::beast::websocket::stream< NextLayer >::accept_ex | ( | http::request< Body, http::basic_fields< Allocator >> const & | req, |
ResponseDecorator const & | decorator | ||
) |
Respond to a WebSocket HTTP Upgrade request
This function is used to synchronously send the HTTP response to an HTTP request possibly containing a WebSocket Upgrade. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.
req | An object containing the HTTP Upgrade request. Ownership is not transferred, the implementation will not access this object from other threads. |
decorator | A function object which will be called to modify the HTTP response object delivered by the implementation. This could be used to set the Server field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
system_error | Thrown on failure. |
void boost::beast::websocket::stream< NextLayer >::accept_ex | ( | http::request< Body, http::basic_fields< Allocator >> const & | req, |
ResponseDecorator const & | decorator, | ||
error_code & | ec | ||
) |
Respond to a WebSocket HTTP Upgrade request
This function is used to synchronously send the HTTP response to an HTTP request possibly containing a WebSocket Upgrade. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When this call returns, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure.
req | An object containing the HTTP Upgrade request. Ownership is not transferred, the implementation will not access this object from other threads. |
decorator | A function object which will be called to modify the HTTP response object delivered by the implementation. This could be used to set the Server field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
ec | Set to indicate what error occurred, if any. |
async_return_type< AcceptHandler, void(error_code)> boost::beast::websocket::stream< NextLayer >::async_accept | ( | AcceptHandler && | handler | ) |
Start reading and responding to a WebSocket HTTP Upgrade request.
This function is used to asynchronously read an HTTP WebSocket Upgrade request and send the HTTP response. The function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_read_some
and async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other asynchronous operations until this operation completes.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When the completion handler is invoked, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure, and the completion handler will be invoked with a suitable error code set.
The implementation uses fixed size internal storage to receive the request. If the request is too large, the error error::buffer_overflow will be indicated. Applications that wish to receive larger requests should first read the request using their own buffer and a suitable overload of http::read or http::async_read, then call accept or async_accept with the request.
handler | The handler to be called when the request completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
std::enable_if< !http::detail::is_header< ConstBufferSequence >::value, async_return_type< AcceptHandler, void(error_code)> >::type boost::beast::websocket::stream< NextLayer >::async_accept | ( | ConstBufferSequence const & | buffers, |
AcceptHandler && | handler | ||
) |
Start reading and responding to a WebSocket HTTP Upgrade request.
This function is used to asynchronously read an HTTP WebSocket Upgrade request and send the HTTP response. The function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_read_some
and async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other asynchronous operations until this operation completes.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When the completion handler is invoked, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure, and the completion handler will be invoked with a suitable error code set.
The implementation uses fixed size internal storage to receive the request. If the request is too large, the error error::buffer_overflow will be indicated. Applications that wish to receive larger requests should first read the request using their own buffer and a suitable overload of http::read or http::async_read, then call accept or async_accept with the request.
buffers | Caller provided data that has already been received on the stream. This may be used for implementations allowing multiple protocols on the same stream. The buffered data will first be applied to the handshake, and then to received WebSocket frames. The implementation will copy the caller provided data before the function returns. |
handler | The handler to be called when the request completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
async_return_type< AcceptHandler, void(error_code)> boost::beast::websocket::stream< NextLayer >::async_accept | ( | http::request< Body, http::basic_fields< Allocator >> const & | req, |
AcceptHandler && | handler | ||
) |
Start responding to a WebSocket HTTP Upgrade request.
This function is used to asynchronously send the HTTP response to an HTTP request possibly containing a WebSocket Upgrade request. The function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other operations until this operation completes.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When the completion handler is invoked, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure, and the completion handler will be invoked with a suitable error code set.
req | An object containing the HTTP Upgrade request. Ownership is not transferred, the implementation will not access this object from other threads. |
handler | The handler to be called when the request completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
async_return_type< AcceptHandler, void(error_code)> boost::beast::websocket::stream< NextLayer >::async_accept_ex | ( | ResponseDecorator const & | decorator, |
AcceptHandler && | handler | ||
) |
Start reading and responding to a WebSocket HTTP Upgrade request.
This function is used to asynchronously read an HTTP WebSocket Upgrade request and send the HTTP response. The function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_read_some
and async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other asynchronous operations until this operation completes.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When the completion handler is invoked, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure, and the completion handler will be invoked with a suitable error code set.
The implementation uses fixed size internal storage to receive the request. If the request is too large, the error error::buffer_overflow will be indicated. Applications that wish to receive larger requests should first read the request using their own buffer and a suitable overload of http::read or http::async_read, then call accept or async_accept with the request.
decorator | A function object which will be called to modify the HTTP response object delivered by the implementation. This could be used to set the Server field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
handler | The handler to be called when the request completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
std::enable_if< !http::detail::is_header< ConstBufferSequence >::value, async_return_type< AcceptHandler, void(error_code)> >::type boost::beast::websocket::stream< NextLayer >::async_accept_ex | ( | ConstBufferSequence const & | buffers, |
ResponseDecorator const & | decorator, | ||
AcceptHandler && | handler | ||
) |
Start reading and responding to a WebSocket HTTP Upgrade request.
This function is used to asynchronously read an HTTP WebSocket Upgrade request and send the HTTP response. The function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_read_some
and async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other asynchronous operations until this operation completes.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When the completion handler is invoked, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure, and the completion handler will be invoked with a suitable error code set.
The implementation uses fixed size internal storage to receive the request. If the request is too large, the error error::buffer_overflow will be indicated. Applications that wish to receive larger requests should first read the request using their own buffer and a suitable overload of http::read or http::async_read, then call accept or async_accept with the request.
buffers | Caller provided data that has already been received on the stream. This may be used for implementations allowing multiple protocols on the same stream. The buffered data will first be applied to the handshake, and then to received WebSocket frames. The implementation will copy the caller provided data before the function returns. |
decorator | A function object which will be called to modify the HTTP response object delivered by the implementation. This could be used to set the Server field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
handler | The handler to be called when the request completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
async_return_type< AcceptHandler, void(error_code)> boost::beast::websocket::stream< NextLayer >::async_accept_ex | ( | http::request< Body, http::basic_fields< Allocator >> const & | req, |
ResponseDecorator const & | decorator, | ||
AcceptHandler && | handler | ||
) |
Start responding to a WebSocket HTTP Upgrade request.
This function is used to asynchronously send the HTTP response to an HTTP request possibly containing a WebSocket Upgrade request. The function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other operations until this operation completes.
If the stream receives a valid HTTP WebSocket Upgrade request, an HTTP response is sent back indicating a successful upgrade. When the completion handler is invoked, the stream is then ready to send and receive WebSocket protocol frames and messages. If the HTTP Upgrade request is invalid or cannot be satisfied, an HTTP response is sent indicating the reason and status code (typically 400, "Bad Request"). This counts as a failure, and the completion handler will be invoked with a suitable error code set.
req | An object containing the HTTP Upgrade request. Ownership is not transferred, the implementation will not access this object from other threads. |
decorator | A function object which will be called to modify the HTTP response object delivered by the implementation. This could be used to set the Server field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
handler | The handler to be called when the request completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
async_return_type< CloseHandler, void(error_code)> boost::beast::websocket::stream< NextLayer >::async_close | ( | close_reason const & | cr, |
CloseHandler && | handler | ||
) |
Start an asynchronous operation to send a WebSocket close frame.
This function is used to asynchronously send a close frame on the stream. This function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other write operations (such as async_ping, stream::async_write, stream::async_write_some, or stream::async_close) until this operation completes.
If the close reason specifies a close code other than beast::websocket::close_code::none, the close frame is sent with the close code and optional reason string. Otherwise, the close frame is sent with no payload.
Callers should not attempt to write WebSocket data after initiating the close. Instead, callers should continue reading until an error occurs. A read returning error::closed indicates a successful connection closure.
cr | The reason for the close. |
handler | The handler to be called when the close operation completes. Copies will be made of the handler as required. The function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
async_return_type< HandshakeHandler, void(error_code)> boost::beast::websocket::stream< NextLayer >::async_handshake | ( | string_view | host, |
string_view | target, | ||
HandshakeHandler && | handler | ||
) |
Start an asynchronous operation to send an upgrade request and receive the response.
This function is used to asynchronously send the HTTP WebSocket upgrade request and receive the HTTP WebSocket Upgrade response. This function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_read_some
and async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other operations until this operation completes.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
host | The name of the remote host, required by the HTTP protocol. Copies may be made as needed. |
target | The Request Target, which may not be empty, required by the HTTP protocol. Copies of this parameter may be made as needed. |
handler | The handler to be called when the request completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
async_return_type< HandshakeHandler, void(error_code)> boost::beast::websocket::stream< NextLayer >::async_handshake | ( | response_type & | res, |
string_view | host, | ||
string_view | target, | ||
HandshakeHandler && | handler | ||
) |
Start an asynchronous operation to send an upgrade request and receive the response.
This function is used to asynchronously send the HTTP WebSocket upgrade request and receive the HTTP WebSocket Upgrade response. This function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_read_some
and async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other operations until this operation completes.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
res | The HTTP Upgrade response returned by the remote endpoint. The caller must ensure this object is valid for at least until the completion handler is invoked. |
host | The name of the remote host, required by the HTTP protocol. Copies may be made as needed. |
target | The Request Target, which may not be empty, required by the HTTP protocol. Copies of this parameter may be made as needed. |
handler | The handler to be called when the request completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
async_return_type< HandshakeHandler, void(error_code)> boost::beast::websocket::stream< NextLayer >::async_handshake_ex | ( | string_view | host, |
string_view | target, | ||
RequestDecorator const & | decorator, | ||
HandshakeHandler && | handler | ||
) |
Start an asynchronous operation to send an upgrade request and receive the response.
This function is used to asynchronously send the HTTP WebSocket upgrade request and receive the HTTP WebSocket Upgrade response. This function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_read_some
and async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other operations until this operation completes.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
host | The name of the remote host, required by the HTTP protocol. Copies may be made as needed. |
target | The Request Target, which may not be empty, required by the HTTP protocol. Copies of this parameter may be made as needed. |
decorator | A function object which will be called to modify the HTTP request object generated by the implementation. This could be used to set the User-Agent field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
handler | The handler to be called when the request completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
async_return_type< HandshakeHandler, void(error_code)> boost::beast::websocket::stream< NextLayer >::async_handshake_ex | ( | response_type & | res, |
string_view | host, | ||
string_view | target, | ||
RequestDecorator const & | decorator, | ||
HandshakeHandler && | handler | ||
) |
Start an asynchronous operation to send an upgrade request and receive the response.
This function is used to asynchronously send the HTTP WebSocket upgrade request and receive the HTTP WebSocket Upgrade response. This function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_read_some
and async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other operations until this operation completes.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
res | The HTTP Upgrade response returned by the remote endpoint. The caller must ensure this object is valid for at least until the completion handler is invoked. |
host | The name of the remote host, required by the HTTP protocol. Copies may be made as needed. |
target | The Request Target, which may not be empty, required by the HTTP protocol. Copies of this parameter may be made as needed. |
decorator | A function object which will be called to modify the HTTP request object generated by the implementation. This could be used to set the User-Agent field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
handler | The handler to be called when the request completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
async_return_type< WriteHandler, void(error_code)> boost::beast::websocket::stream< NextLayer >::async_ping | ( | ping_data const & | payload, |
WriteHandler && | handler | ||
) |
Start an asynchronous operation to send a WebSocket ping frame.
This function is used to asynchronously send a ping frame to the stream. The function call always returns immediately. The asynchronous operation will continue until one of the following is true:
This operation is implemented in terms of one or more calls to the next layer's async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other writes until this operation completes.
If a close frame is sent or received before the ping frame is sent, the completion handler will be called with the error set to boost::asio::error::operation_aborted
.
payload | The payload of the ping message, which may be empty. |
handler | The handler to be called when the read operation completes. Copies will be made of the handler as required. The function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
async_return_type< WriteHandler, void(error_code)> boost::beast::websocket::stream< NextLayer >::async_pong | ( | ping_data const & | payload, |
WriteHandler && | handler | ||
) |
Start an asynchronous operation to send a WebSocket pong frame.
This function is used to asynchronously send a pong frame to the stream. The function call always returns immediately. The asynchronous operation will continue until one of the following is true:
This operation is implemented in terms of one or more calls to the next layer's async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other writes until this operation completes.
The WebSocket protocol allows pong frames to be sent from either end at any time. It is not necessary to first receive a ping in order to send a pong. The remote peer may use the receipt of a pong frame as an indication that the connection is not dead.
If a close frame is sent or received before the pong frame is sent, the completion handler will be called with the error set to boost::asio::error::operation_aborted
.
payload | The payload of the pong message, which may be empty. |
handler | The handler to be called when the read operation completes. Copies will be made of the handler as required. The function signature of the handler must be: Regardless of whether the asynchronous operation completes immediately or not, the handler will not be invoked from within this function. Invocation of the handler will be performed in a manner equivalent to using boost::asio::io_service::post . |
async_return_type< ReadHandler, void(error_code, std::size_t)> boost::beast::websocket::stream< NextLayer >::async_read | ( | DynamicBuffer & | buffer, |
ReadHandler && | handler | ||
) |
Read a message asynchronously
This function is used to asynchronously read a complete message from the stream. The function call always returns immediately. The asynchronous operation will continue until one of the following is true:
This operation is implemented in terms of one or more calls to the next layer's async_read_some
and async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other reads until this operation completes.
Received message data, if any, is appended to the input area of the buffer. The functions got_binary and got_text may be used to query the stream and determine the type of the last received message.
While this operation is active, the implementation will read incoming control frames and handle them automatically as follows:
Because of the need to handle control frames, asynchronous read operations can cause writes to take place. These writes are managed transparently; callers can still have one active asynchronous read and asynchronous write operation pending simultaneously (a user initiated call to async_close counts as a write).
buffer | A dynamic buffer to hold the message data after any masking or decompression has been applied. This object must remain valid until the handler is called. |
handler | The handler to be called when the read operation completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: void handler( std::size_t bytes_written // Number of bytes appended to buffer ); boost::asio::io_service::post . |
async_return_type< ReadHandler, void(error_code, std::size_t)> boost::beast::websocket::stream< NextLayer >::async_read_some | ( | DynamicBuffer & | buffer, |
std::size_t | limit, | ||
ReadHandler && | handler | ||
) |
Read part of a message asynchronously
This function is used to asynchronously read part of a message from the stream. The function call always returns immediately. The asynchronous operation will continue until one of the following is true:
This operation is implemented in terms of one or more calls to the next layer's async_read_some
and async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other reads until this operation completes.
Received message data, if any, is appended to the input area of the buffer. The functions got_binary and got_text may be used to query the stream and determine the type of the last received message. The function is_message_done may be called to determine if the message received by the last read operation is complete.
While this operation is active, the implementation will read incoming control frames and handle them automatically as follows:
Because of the need to handle control frames, asynchronous read operations can cause writes to take place. These writes are managed transparently; callers can still have one active asynchronous read and asynchronous write operation pending simultaneously (a user initiated call to async_close counts as a write).
buffer | A dynamic buffer to hold the message data after any masking or decompression has been applied. This object must remain valid until the handler is called. |
limit | An upper limit on the number of bytes this function will append into the buffer. If this value is zero, then a reasonable size will be chosen automatically. |
handler | The handler to be called when the read operation completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: void handler( std::size_t bytes_written // Number of bytes appended to buffer ); boost::asio::io_service::post . |
async_return_type< ReadHandler, void(error_code, std::size_t)> boost::beast::websocket::stream< NextLayer >::async_read_some | ( | MutableBufferSequence const & | buffers, |
ReadHandler && | handler | ||
) |
Read part of a message asynchronously
This function is used to asynchronously read part of a message from the stream. The function call always returns immediately. The asynchronous operation will continue until one of the following is true:
This operation is implemented in terms of one or more calls to the next layer's async_read_some
and async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other reads until this operation completes.
Received message data, if any, is written to the buffer sequence. The functions got_binary and got_text may be used to query the stream and determine the type of the last received message. The function is_message_done may be called to determine if the message received by the last read operation is complete.
While this operation is active, the implementation will read incoming control frames and handle them automatically as follows:
Because of the need to handle control frames, asynchronous read operations can cause writes to take place. These writes are managed transparently; callers can still have one active asynchronous read and asynchronous write operation pending simultaneously (a user initiated call to async_close counts as a write).
buffers | The buffer sequence into which message data will be placed after any masking or decompresison has been applied. The implementation will make copies of this object as needed, but ownership of the underlying memory is not transferred. The caller is responsible for ensuring that the memory locations pointed to by the buffer sequence remains valid until the completion handler is called. |
handler | The handler to be called when the read operation completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: void handler( std::size_t bytes_written // Number of bytes written to the buffer sequence ); boost::asio::io_service::post . |
async_return_type< WriteHandler, void(error_code, std::size_t)> boost::beast::websocket::stream< NextLayer >::async_write | ( | ConstBufferSequence const & | buffers, |
WriteHandler && | handler | ||
) |
Start an asynchronous operation to write a message to the stream.
This function is used to asynchronously write a message to the stream. The function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_write_some
functions, and is known as a composed operation. The program must ensure that the stream performs no other write operations (such as stream::async_write, stream::async_write_some, or stream::async_close).
The current setting of the binary option controls whether the message opcode is set to text or binary. If the auto_fragment option is set, the message will be split into one or more frames as necessary. The actual payload contents sent may be transformed as per the WebSocket protocol settings.
buffers | The buffers containing the entire message payload. The implementation will make copies of this object as needed, but ownership of the underlying memory is not transferred. The caller is responsible for ensuring that the memory locations pointed to by buffers remains valid until the completion handler is called. |
handler | The handler to be called when the write operation completes. Copies will be made of the handler as required. The function signature of the handler must be: void handler( std::size_t bytes_transferred // Number of bytes written from the // buffers. If an error occurred, // this will be less than the sum // of the buffer sizes. ); boost::asio::io_service::post . |
async_return_type< WriteHandler, void(error_code, std::size_t)> boost::beast::websocket::stream< NextLayer >::async_write_some | ( | bool | fin, |
ConstBufferSequence const & | buffers, | ||
WriteHandler && | handler | ||
) |
Start an asynchronous operation to send a message frame on the stream.
This function is used to asynchronously write a message frame on the stream. This function call always returns immediately. The asynchronous operation will continue until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the next layer's async_write_some
functions, and is known as a composed operation. The actual payload sent may be transformed as per the WebSocket protocol settings. The program must ensure that the stream performs no other write operations (such as stream::async_write, stream::async_write_some, or stream::async_close).
If this is the beginning of a new message, the message opcode will be set to text or binary as per the current setting of the binary option. The actual payload sent may be transformed as per the WebSocket protocol settings.
fin | true if this is the last part of the message. |
buffers | A object meeting the requirements of ConstBufferSequence which holds the payload data before any masking or compression. Although the buffers object may be copied as necessary, ownership of the underlying buffers is retained by the caller, which must guarantee that they remain valid until the handler is called. |
handler | The handler to be called when the write completes. Copies will be made of the handler as required. The equivalent function signature of the handler must be: void handler( std::size_t bytes_transferred // Number of bytes written from the // buffers. If an error occurred, // this will be less than the sum // of the buffer sizes. ); |
|
inline |
Set the automatic fragmentation option.
Determines if outgoing message payloads are broken up into multiple pieces.
When the automatic fragmentation size is turned on, outgoing message payloads are broken up into multiple frames no larger than the write buffer size.
The default setting is to fragment messages.
value | A bool indicating if auto fragmentation should be on. |
|
inline |
Returns true
if the automatic fragmentation option is set.
|
inline |
Set the binary message option.
This controls whether or not outgoing message opcodes are set to binary or text. The setting is only applied at the start when a caller begins a new message. Changing the opcode after a message is started will only take effect after the current message being sent is complete.
The default setting is to send text messages.
value | true if outgoing messages should indicate binary, or false if they should indicate text. |
|
inline |
Returns true
if the binary message option is set.
void boost::beast::websocket::stream< NextLayer >::close | ( | close_reason const & | cr | ) |
Send a WebSocket close frame.
This function is used to synchronously send a close frame on the stream. The call blocks until one of the following is true:
This function is implemented in terms of one or more calls to the next layer's write_some
functions.
If the close reason specifies a close code other than beast::websocket::close_code::none, the close frame is sent with the close code and optional reason string. Otherwise, the close frame is sent with no payload.
Callers should not attempt to write WebSocket data after initiating the close. Instead, callers should continue reading until an error occurs. A read returning error::closed indicates a successful connection closure.
cr | The reason for the close. |
system_error | Thrown on failure. |
void boost::beast::websocket::stream< NextLayer >::close | ( | close_reason const & | cr, |
error_code & | ec | ||
) |
Send a WebSocket close frame.
This function is used to synchronously send a close frame on the stream. The call blocks until one of the following is true:
This function is implemented in terms of one or more calls to the next layer's write_some
functions.
If the close reason specifies a close code other than beast::websocket::close_code::none, the close frame is sent with the close code and optional reason string. Otherwise, the close frame is sent with no payload.
Callers should not attempt to write WebSocket data after initiating the close. Instead, callers should continue reading until an error occurs. A read returning error::closed indicates a successful connection closure.
cr | The reason for the close. |
ec | Set to indicate what error occurred, if any. |
|
inline |
Set a callback to be invoked on each incoming control frame.
Sets the callback to be invoked whenever a ping, pong, or close control frame is received during a call to one of the following functions:
Unlike completion handlers, the callback will be invoked for each control frame during a call to any synchronous or asynchronous read function. The operation is passive, with no associated error code, and triggered by reads.
For close frames, the close reason code may be obtained by calling the function reason.
cb | The function object to call, which must be invocable with this equivalent signature: void callback( frame_type kind, // The type of frame string_view payload // The payload in the frame ); |
|
inline |
Reset the control frame callback.
This function removes any previously set control frame callback.
|
inline |
Return the io_service
associated with the stream
This function may be used to obtain the io_service
object that the stream uses to dispatch handlers for asynchronous operations.
|
inline |
Get the permessage-deflate extension options.
|
inline |
Returns true
if the latest message data indicates binary.
This function informs the caller of whether the last received message frame represents a message with the binary opcode.
If there is no last message frame, the return value is undefined.
|
inline |
Returns true
if the latest message data indicates text.
This function informs the caller of whether the last received message frame represents a message with the text opcode.
If there is no last message frame, the return value is undefined.
void boost::beast::websocket::stream< NextLayer >::handshake | ( | string_view | host, |
string_view | target | ||
) |
Send an HTTP WebSocket Upgrade request and receive the response.
This function is used to synchronously send the WebSocket upgrade HTTP request. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
host | The name of the remote host, required by the HTTP protocol. |
target | The Request Target, which may not be empty, required by the HTTP protocol. |
system_error | Thrown on failure. |
void boost::beast::websocket::stream< NextLayer >::handshake | ( | response_type & | res, |
string_view | host, | ||
string_view | target | ||
) |
Send an HTTP WebSocket Upgrade request and receive the response.
This function is used to synchronously send the WebSocket upgrade HTTP request. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
res | The HTTP Upgrade response returned by the remote endpoint. |
host | The name of the remote host, required by the HTTP protocol. |
target | The Request Target, which may not be empty, required by the HTTP protocol. |
system_error | Thrown on failure. |
void boost::beast::websocket::stream< NextLayer >::handshake | ( | string_view | host, |
string_view | target, | ||
error_code & | ec | ||
) |
Send an HTTP WebSocket Upgrade request and receive the response.
This function is used to synchronously send the WebSocket upgrade HTTP request. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
host | The name of the remote host, required by the HTTP protocol. |
target | The Request Target, which may not be empty, required by the HTTP protocol. |
ec | Set to indicate what error occurred, if any. |
void boost::beast::websocket::stream< NextLayer >::handshake | ( | response_type & | res, |
string_view | host, | ||
string_view | target, | ||
error_code & | ec | ||
) |
Send an HTTP WebSocket Upgrade request and receive the response.
This function is used to synchronously send the WebSocket upgrade HTTP request. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
res | The HTTP Upgrade response returned by the remote endpoint. If ec is set, the returned value is undefined. |
host | The name of the remote host, required by the HTTP protocol. |
target | The Request Target, which may not be empty, required by the HTTP protocol. |
ec | Set to indicate what error occurred, if any. |
void boost::beast::websocket::stream< NextLayer >::handshake_ex | ( | string_view | host, |
string_view | target, | ||
RequestDecorator const & | decorator | ||
) |
Send an HTTP WebSocket Upgrade request and receive the response.
This function is used to synchronously send the WebSocket upgrade HTTP request. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
host | The name of the remote host, required by the HTTP protocol. |
target | The Request Target, which may not be empty, required by the HTTP protocol. |
decorator | A function object which will be called to modify the HTTP request object generated by the implementation. This could be used to set the User-Agent field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
system_error | Thrown on failure. |
void boost::beast::websocket::stream< NextLayer >::handshake_ex | ( | response_type & | res, |
string_view | host, | ||
string_view | target, | ||
RequestDecorator const & | decorator | ||
) |
Send an HTTP WebSocket Upgrade request and receive the response.
This function is used to synchronously send the WebSocket upgrade HTTP request. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
res | The HTTP Upgrade response returned by the remote endpoint. |
host | The name of the remote host, required by the HTTP protocol. |
target | The Request Target, which may not be empty, required by the HTTP protocol. |
decorator | A function object which will be called to modify the HTTP request object generated by the implementation. This could be used to set the User-Agent field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
system_error | Thrown on failure. |
void boost::beast::websocket::stream< NextLayer >::handshake_ex | ( | string_view | host, |
string_view | target, | ||
RequestDecorator const & | decorator, | ||
error_code & | ec | ||
) |
Send an HTTP WebSocket Upgrade request and receive the response.
This function is used to synchronously send the WebSocket upgrade HTTP request. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
host | The name of the remote host, required by the HTTP protocol. |
target | The Request Target, which may not be empty, required by the HTTP protocol. |
decorator | A function object which will be called to modify the HTTP request object generated by the implementation. This could be used to set the User-Agent field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
ec | Set to indicate what error occurred, if any. |
void boost::beast::websocket::stream< NextLayer >::handshake_ex | ( | response_type & | res, |
string_view | host, | ||
string_view | target, | ||
RequestDecorator const & | decorator, | ||
error_code & | ec | ||
) |
Send an HTTP WebSocket Upgrade request and receive the response.
This function is used to synchronously send the WebSocket upgrade HTTP request. The call blocks until one of the following conditions is true:
This function is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
The operation is successful if the received HTTP response indicates a successful HTTP Upgrade (represented by a Status-Code of 101, "switching protocols").
res | The HTTP Upgrade response returned by the remote endpoint. |
host | The name of the remote host, required by the HTTP protocol. |
target | The Request Target, which may not be empty, required by the HTTP protocol. |
decorator | A function object which will be called to modify the HTTP request object generated by the implementation. This could be used to set the User-Agent field, subprotocols, or other application or HTTP specific fields. The object will be called with this equivalent signature: |
ec | Set to indicate what error occurred, if any. |
|
inline |
Returns true
if the last completed read finished the current message.
|
inline |
Returns true
if the stream is open.
The stream is open after a successful handshake, and when no error has occurred.
|
inline |
Get a reference to the lowest layer
This function returns a reference to the lowest layer in a stack of stream layers.
|
inline |
Get a reference to the lowest layer
This function returns a reference to the lowest layer in a stack of stream layers.
|
inline |
Get a reference to the next layer
This function returns a reference to the next layer in a stack of stream layers.
|
inline |
Get a reference to the next layer
This function returns a reference to the next layer in a stack of stream layers.
|
default |
Assignment
If NextLayer
is move assignable, this function will move-assign a new stream from the existing stream.
void boost::beast::websocket::stream< NextLayer >::ping | ( | ping_data const & | payload | ) |
Send a WebSocket ping frame.
This function is used to synchronously send a ping frame on the stream. The call blocks until one of the following is true:
This function is implemented in terms of one or more calls to the next layer's write_some
functions.
payload | The payload of the ping message, which may be empty. |
system_error | Thrown on failure. |
void boost::beast::websocket::stream< NextLayer >::ping | ( | ping_data const & | payload, |
error_code & | ec | ||
) |
Send a WebSocket ping frame.
This function is used to synchronously send a ping frame on the stream. The call blocks until one of the following is true:
This function is implemented in terms of one or more calls to the next layer's write_some
functions.
payload | The payload of the ping message, which may be empty. |
ec | Set to indicate what error occurred, if any. |
void boost::beast::websocket::stream< NextLayer >::pong | ( | ping_data const & | payload | ) |
Send a WebSocket pong frame.
This function is used to synchronously send a pong frame on the stream. The call blocks until one of the following is true:
This function is implemented in terms of one or more calls to the next layer's write_some
functions.
The WebSocket protocol allows pong frames to be sent from either end at any time. It is not necessary to first receive a ping in order to send a pong. The remote peer may use the receipt of a pong frame as an indication that the connection is not dead.
payload | The payload of the pong message, which may be empty. |
system_error | Thrown on failure. |
void boost::beast::websocket::stream< NextLayer >::pong | ( | ping_data const & | payload, |
error_code & | ec | ||
) |
Send a WebSocket pong frame.
This function is used to synchronously send a pong frame on the stream. The call blocks until one of the following is true:
This function is implemented in terms of one or more calls to the next layer's write_some
functions.
The WebSocket protocol allows pong frames to be sent from either end at any time. It is not necessary to first receive a ping in order to send a pong. The remote peer may use the receipt of a pong frame as an indication that the connection is not dead.
payload | The payload of the pong message, which may be empty. |
ec | Set to indicate what error occurred, if any. |
std::size_t boost::beast::websocket::stream< NextLayer >::read | ( | DynamicBuffer & | buffer | ) |
Read a message
This function is used to synchronously read a complete message from the stream. The call blocks until one of the following is true:
This operation is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
Received message data, if any, is appended to the input area of the buffer. The functions got_binary and got_text may be used to query the stream and determine the type of the last received message.
While this operation is active, the implementation will read incoming control frames and handle them automatically as follows:
buffer | A dynamic buffer to hold the message data after any masking or decompression has been applied. |
system_error | Thrown to indicate an error. The corresponding error code may be retrieved from the exception object for inspection. |
std::size_t boost::beast::websocket::stream< NextLayer >::read | ( | DynamicBuffer & | buffer, |
error_code & | ec | ||
) |
Read a message
This function is used to synchronously read a complete message from the stream. The call blocks until one of the following is true:
This operation is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
Received message data, if any, is appended to the input area of the buffer. The functions got_binary and got_text may be used to query the stream and determine the type of the last received message.
While this operation is active, the implementation will read incoming control frames and handle them automatically as follows:
buffer | A dynamic buffer to hold the message data after any masking or decompression has been applied. |
ec | Set to indicate what error occurred, if any. |
|
inline |
Set the maximum incoming message size option.
Sets the largest permissible incoming message size. Message frame fields indicating a size that would bring the total message size over this limit will cause a protocol failure.
The default setting is 16 megabytes. A value of zero indicates a limit of the maximum value of a std::uint64_t
.
amount | The limit on the size of incoming messages. |
|
inline |
Returns the maximum incoming message size setting.
std::size_t boost::beast::websocket::stream< NextLayer >::read_size_hint | ( | std::size_t | initial_size = +tcp_frame_size | ) | const |
Returns a suggested maximum buffer size for the next call to read.
This function returns a reasonable upper limit on the number of bytes for the size of the buffer passed in the next call to read. The number is determined by the state of the current frame and whether or not the permessage-deflate extension is enabled.
initial_size | A non-zero size representing the caller's desired buffer size for when there is no information which may be used to calculate a more specific value. For example, when reading the first frame header of a message. |
std::size_t boost::beast::websocket::stream< NextLayer >::read_size_hint | ( | DynamicBuffer & | buffer | ) | const |
Returns a suggested maximum buffer size for the next call to read.
This function returns a reasonable upper limit on the number of bytes for the size of the buffer passed in the next call to read. The number is determined by the state of the current frame and whether or not the permessage-deflate extension is enabled.
buffer | The buffer which will be used for reading. The implementation will query the buffer to obtain the optimum size of a subsequent call to buffer.prepare based on the state of the current frame, if any. |
std::size_t boost::beast::websocket::stream< NextLayer >::read_some | ( | DynamicBuffer & | buffer, |
std::size_t | limit | ||
) |
Read part of a message
This function is used to synchronously read some message data from the stream. The call blocks until one of the following is true:
This operation is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
Received message data, if any, is appended to the input area of the buffer. The functions got_binary and got_text may be used to query the stream and determine the type of the last received message. The function is_message_done may be called to determine if the message received by the last read operation is complete.
While this operation is active, the implementation will read incoming control frames and handle them automatically as follows:
buffer | A dynamic buffer to hold the message data after any masking or decompression has been applied. |
limit | An upper limit on the number of bytes this function will append into the buffer. If this value is zero, then a reasonable size will be chosen automatically. |
system_error | Thrown to indicate an error. The corresponding error code may be retrieved from the exception object for inspection. |
std::size_t boost::beast::websocket::stream< NextLayer >::read_some | ( | DynamicBuffer & | buffer, |
std::size_t | limit, | ||
error_code & | ec | ||
) |
Read part of a message
This function is used to synchronously read some message data from the stream. The call blocks until one of the following is true:
This operation is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
Received message data, if any, is appended to the input area of the buffer. The functions got_binary and got_text may be used to query the stream and determine the type of the last received message. The function is_message_done may be called to determine if the message received by the last read operation is complete.
While this operation is active, the implementation will read incoming control frames and handle them automatically as follows:
buffer | A dynamic buffer to hold the message data after any masking or decompression has been applied. |
limit | An upper limit on the number of bytes this function will append into the buffer. If this value is zero, then a reasonable size will be chosen automatically. |
ec | Set to indicate what error occurred, if any. |
std::size_t boost::beast::websocket::stream< NextLayer >::read_some | ( | MutableBufferSequence const & | buffers | ) |
Read part of a message
This function is used to synchronously read some message data from the stream. The call blocks until one of the following is true:
This operation is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
Received message data, if any, is written to the buffer sequence. The functions got_binary and got_text may be used to query the stream and determine the type of the last received message. The function is_message_done may be called to determine if the message received by the last read operation is complete.
While this operation is active, the implementation will read incoming control frames and handle them automatically as follows:
buffers | A buffer sequence to hold the message data after any masking or decompression has been applied. |
system_error | Thrown to indicate an error. The corresponding error code may be retrieved from the exception object for inspection. |
std::size_t boost::beast::websocket::stream< NextLayer >::read_some | ( | MutableBufferSequence const & | buffers, |
error_code & | ec | ||
) |
Read part of a message
This function is used to synchronously read some message data from the stream. The call blocks until one of the following is true:
This operation is implemented in terms of one or more calls to the next layer's read_some
and write_some
functions.
Received message data, if any, is written to the buffer sequence. The functions got_binary and got_text may be used to query the stream and determine the type of the last received message. The function is_message_done may be called to determine if the message received by the last read operation is complete.
While this operation is active, the implementation will read incoming control frames and handle them automatically as follows:
buffers | A buffer sequence to hold the message data after any masking or decompression has been applied. |
ec | Set to indicate what error occurred, if any. |
|
inline |
Returns the close reason received from the peer.
This is only valid after a read completes with error::closed.
void boost::beast::websocket::stream< NextLayer >::set_option | ( | permessage_deflate const & | o | ) |
Set the permessage-deflate extension options.
|
inline |
Set the text message option.
This controls whether or not outgoing message opcodes are set to binary or text. The setting is only applied at the start when a caller begins a new message. Changing the opcode after a message is started will only take effect after the current message being sent is complete.
The default setting is to send text messages.
value | true if outgoing messages should indicate text, or false if they should indicate binary. |
|
inline |
Returns true
if the text message option is set.
std::size_t boost::beast::websocket::stream< NextLayer >::write | ( | ConstBufferSequence const & | buffers | ) |
Write a message to the stream.
This function is used to synchronously write a message to the stream. The call blocks until one of the following conditions is met:
This operation is implemented in terms of one or more calls to the next layer's write_some
function.
The current setting of the binary option controls whether the message opcode is set to text or binary. If the auto_fragment option is set, the message will be split into one or more frames as necessary. The actual payload contents sent may be transformed as per the WebSocket protocol settings.
buffers | The buffers containing the entire message payload. The implementation will make copies of this object as needed, but ownership of the underlying memory is not transferred. The caller is responsible for ensuring that the memory locations pointed to by buffers remains valid until the completion handler is called. |
system_error | Thrown on failure. |
std::size_t boost::beast::websocket::stream< NextLayer >::write | ( | ConstBufferSequence const & | buffers, |
error_code & | ec | ||
) |
Write a message to the stream.
This function is used to synchronously write a message to the stream. The call blocks until one of the following conditions is met:
This operation is implemented in terms of one or more calls to the next layer's write_some
function.
The current setting of the binary option controls whether the message opcode is set to text or binary. If the auto_fragment option is set, the message will be split into one or more frames as necessary. The actual payload contents sent may be transformed as per the WebSocket protocol settings.
buffers | The buffers containing the entire message payload. The implementation will make copies of this object as needed, but ownership of the underlying memory is not transferred. The caller is responsible for ensuring that the memory locations pointed to by buffers remains valid until the completion handler is called. |
ec | Set to indicate what error occurred, if any. |
system_error | Thrown on failure. |
|
inline |
Set the write buffer size option.
Sets the size of the write buffer used by the implementation to send frames. The write buffer is needed when masking payload data in the client role, compressing frames, or auto-fragmenting message data.
Lowering the size of the buffer can decrease the memory requirements for each connection, while increasing the size of the buffer can reduce the number of calls made to the next layer to write data.
The default setting is 4096. The minimum value is 8.
The write buffer size can only be changed when the stream is not open. Undefined behavior results if the option is modified after a successful WebSocket handshake.
amount | The size of the write buffer in bytes. |
|
inline |
Returns the size of the write buffer.
std::size_t boost::beast::websocket::stream< NextLayer >::write_some | ( | bool | fin, |
ConstBufferSequence const & | buffers | ||
) |
Write partial message data on the stream.
This function is used to write some or all of a message's payload to the stream. The call will block until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the stream's write_some
function.
If this is the beginning of a new message, the message opcode will be set to text or binary as per the current setting of the binary option. The actual payload sent may be transformed as per the WebSocket protocol settings.
fin | true if this is the last part of the message. |
buffers | The input buffer sequence holding the data to write. |
system_error | Thrown on failure. |
std::size_t boost::beast::websocket::stream< NextLayer >::write_some | ( | bool | fin, |
ConstBufferSequence const & | buffers, | ||
error_code & | ec | ||
) |
Write partial message data on the stream.
This function is used to write some or all of a message's payload to the stream. The call will block until one of the following conditions is true:
This operation is implemented in terms of one or more calls to the stream's write_some
function.
If this is the beginning of a new message, the message opcode will be set to text or binary as per the current setting of the binary option. The actual payload sent may be transformed as per the WebSocket protocol settings.
fin | true if this is the last part of the message. |
ec | Set to indicate what error occurred, if any. |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |