我正在使用 boost::beast 创建 websocket 连接,到目前为止它似乎工作正常。但我无法弄清楚断开连接后是否应该替换 websocket::stream 变量。
即我有一个变量:
boost::beast::websocket::stream<boost::asio::ssl::stream<boost::asio::ip::tcp::socket>> _ws
异步断开连接启动并完成后:
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;
}
如果我想重新启动,我应该替换 _ws 变量吗
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)));
}
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)