boost::redis::connection::set_receive_response

Sets the response object of async_receive2 operations.

Synopsis

template<class Response>
void
set_receive_response(Response& response);

Description

Pushes received by the connection (concretely, by async_run) will be stored in resp. This happens even if async_receive2 is not being called.

resp should be able to accommodate the following message types:

  • Any kind of RESP3 pushes that the application might expect. This usually involves Pub/Sub messages of type message, subscribe, unsubscribe, psubscribe and punsubscribe. See this page for more info.

  • Any errors caused by failed SUBSCRIBE commands. Because of protocol oddities, these are placed in the receive buffer, rather than handed to async_exec.

  • If your application is using MONITOR, simple strings.

Because receive responses need to accommodate many different kind of messages, it's advised to use one of the generic responses (like generic_flat_response). If a response can't accommodate one of the received types, async_run will exit with an error.

Messages received before this function is called are discarded.

Object lifetimes

resp should be kept alive until async_run completes.

Created with MrDocs