I am using boost::beast to create a websocket connection and so far it seems to work fine. But I am unable to figure out if i should replace the websocket::stream variable after disconnect.
i.e. I have a variable:
boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> _ws
After an async disconnect is initiated and completed:
bool WebsocketConnection::startDisconnectSequence()
{
_ws.async_close(
boost::beast::websocket::close_code::normal,
boost::asio::bind_executor(
_strand,
std::bind(
&WebsocketConnection::onClose,
this,
std::placeholders::_1)));
return true;
}
If I want to restart again, should i replace the _ws variable
boost::asio::async_connect(
_ws.next_layer().next_layer(),
results.begin(),
results.end(),
boost::asio::bind_executor(
_strand,
std::bind(
&ASIOConnectionBase::onConnect,
this,
std::placeholders::_1)));
}