mirror of
https://github.com/XRPLF/clio.git
synced 2026-07-27 00:50:39 +00:00
style: Set clang-format width 100 (#2953)
This commit is contained in:
@@ -55,7 +55,11 @@ namespace ssl = boost::asio::ssl;
|
||||
using tcp = boost::asio::ip::tcp;
|
||||
|
||||
void
|
||||
WebSocketSyncClient::connect(std::string const& host, std::string const& port, std::vector<WebHeader> additionalHeaders)
|
||||
WebSocketSyncClient::connect(
|
||||
std::string const& host,
|
||||
std::string const& port,
|
||||
std::vector<WebHeader> additionalHeaders
|
||||
)
|
||||
{
|
||||
auto const results = resolver_.resolve(host, port);
|
||||
auto const ep = net::connect(ws_.next_layer(), results);
|
||||
@@ -67,10 +71,17 @@ WebSocketSyncClient::connect(std::string const& host, std::string const& port, s
|
||||
|
||||
ws_.set_option(
|
||||
boost::beast::websocket::stream_base::decorator(
|
||||
[additionalHeaders = std::move(additionalHeaders)](boost::beast::websocket::request_type& req) {
|
||||
req.set(http::field::user_agent, std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro");
|
||||
[additionalHeaders =
|
||||
std::move(additionalHeaders)](boost::beast::websocket::request_type& req) {
|
||||
req.set(
|
||||
http::field::user_agent,
|
||||
std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"
|
||||
);
|
||||
for (auto const& header : additionalHeaders) {
|
||||
std::visit([&header, &req](auto const& name) { req.set(name, header.value); }, header.name);
|
||||
std::visit(
|
||||
[&header, &req](auto const& name) { req.set(name, header.value); },
|
||||
header.name
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -110,9 +121,16 @@ WebServerSslSyncClient::connect(std::string const& host, std::string const& port
|
||||
net::connect(ws_->next_layer().next_layer(), results.begin(), results.end());
|
||||
ws_->next_layer().handshake(ssl::stream_base::client);
|
||||
|
||||
ws_->set_option(boost::beast::websocket::stream_base::decorator([](boost::beast::websocket::request_type& req) {
|
||||
req.set(http::field::user_agent, std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro");
|
||||
}));
|
||||
ws_->set_option(
|
||||
boost::beast::websocket::stream_base::decorator(
|
||||
[](boost::beast::websocket::request_type& req) {
|
||||
req.set(
|
||||
http::field::user_agent,
|
||||
std::string(BOOST_BEAST_VERSION_STRING) + " websocket-client-coro"
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
ws_->handshake(host, "/");
|
||||
}
|
||||
@@ -163,9 +181,13 @@ WebSocketAsyncClient::connect(
|
||||
|
||||
stream_.set_option(
|
||||
boost::beast::websocket::stream_base::decorator(
|
||||
[additionalHeaders = std::move(additionalHeaders)](boost::beast::websocket::request_type& req) {
|
||||
[additionalHeaders =
|
||||
std::move(additionalHeaders)](boost::beast::websocket::request_type& req) {
|
||||
for (auto const& header : additionalHeaders) {
|
||||
std::visit([&header, &req](auto const& name) { req.set(name, header.value); }, header.name);
|
||||
std::visit(
|
||||
[&header, &req](auto const& name) { req.set(name, header.value); },
|
||||
header.name
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -186,7 +208,9 @@ WebSocketAsyncClient::send(
|
||||
)
|
||||
{
|
||||
auto const error = util::withTimeout(
|
||||
[this, &message](auto&& cyield) { stream_.async_write(net::buffer(message), cyield); }, yield, timeout
|
||||
[this, &message](auto&& cyield) { stream_.async_write(net::buffer(message), cyield); },
|
||||
yield,
|
||||
timeout
|
||||
);
|
||||
|
||||
if (error)
|
||||
@@ -195,18 +219,25 @@ WebSocketAsyncClient::send(
|
||||
}
|
||||
|
||||
std::expected<std::string, boost::system::error_code>
|
||||
WebSocketAsyncClient::receive(boost::asio::yield_context yield, std::chrono::steady_clock::duration timeout)
|
||||
WebSocketAsyncClient::receive(
|
||||
boost::asio::yield_context yield,
|
||||
std::chrono::steady_clock::duration timeout
|
||||
)
|
||||
{
|
||||
boost::beast::flat_buffer buffer{};
|
||||
auto error =
|
||||
util::withTimeout([this, &buffer](auto&& cyield) { stream_.async_read(buffer, cyield); }, yield, timeout);
|
||||
auto error = util::withTimeout(
|
||||
[this, &buffer](auto&& cyield) { stream_.async_read(buffer, cyield); }, yield, timeout
|
||||
);
|
||||
if (error)
|
||||
return std::unexpected{error};
|
||||
return boost::beast::buffers_to_string(buffer.data());
|
||||
}
|
||||
|
||||
void
|
||||
WebSocketAsyncClient::gracefulClose(boost::asio::yield_context yield, std::chrono::steady_clock::duration timeout)
|
||||
WebSocketAsyncClient::gracefulClose(
|
||||
boost::asio::yield_context yield,
|
||||
std::chrono::steady_clock::duration timeout
|
||||
)
|
||||
{
|
||||
boost::beast::websocket::stream_base::timeout wsTimeout{};
|
||||
stream_.get_option(wsTimeout);
|
||||
|
||||
Reference in New Issue
Block a user