Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinniefalco/49a7a7657e456752b68e50216b82725c to your computer and use it in GitHub Desktop.
Save vinniefalco/49a7a7657e456752b68e50216b82725c to your computer and use it in GitHub Desktop.
/** Read a complete message
This function is used to synchronously read a message from the stream.
The call blocks until one of the following is true:
@li A complete message is received.
@li A close frame is received. In this case the error indicated by
the function will be @ref error::closed.
@li An error occurs on the stream.
This operation is implemented in terms of one or more calls to the next
layer's `read_some` and `write_some` functions.
Any received message data is appended to the input area of the buffer.
The functions @ref got_binary and @ref got_text may be used to query
the stream and determine the type of the last received message.
While this read operation is active, the implementation will read
incoming control frames and handle them automatically as follows:
@li The @ref control_callback will be invoked for each control frame.
@li For each received ping frame, a pong frame will be automatically sent.
@li If a close frame is received, the WebSocket close procedure is
performed. In this case, when the function returns, the error
@ref error::closed will be indicated.
@param buffer A dynamic buffer to hold the message data after
any masking or decompression has been applied.
@throws system_error Thrown to indicate an error. The corresponding
error code may be retrieved from the exception object for inspection.
*/
template<class DynamicBuffer>
std::size_t
read(DynamicBuffer& buffer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment