Beast Logo

PrevUpHomeNext
websocket::stream::async_write_frame

Start an asynchronous operation to send a message frame on the stream.

Synopsis
template<
    class ConstBufferSequence,
    class WriteHandler>
void-or-deduced
async_write_frame(
    bool fin,
    ConstBufferSequence const& buffers,
    WriteHandler&& handler);
Description

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 websocket::stream::async_write, websocket::stream::async_write_frame, or websocket::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 websocket::stream::binary option. The actual payload sent may be transformed as per the WebSocket protocol settings.

Parameters

Name

Description

fin

A bool indicating whether or not the frame is the last frame in the corresponding WebSockets 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(
    error_code const& ec    // Result of operation
);

PrevUpHomeNext