refactor
This commit is contained in:
@@ -315,47 +315,46 @@ auto packet_client::send(std::string_view method, packet &request,
|
||||
};
|
||||
|
||||
auto current_client = get_client();
|
||||
if (current_client) {
|
||||
try {
|
||||
auto current_request = base_request;
|
||||
current_request.encode_top(current_client->nonce);
|
||||
request = current_request;
|
||||
if (not current_client) {
|
||||
retry_after_sleep();
|
||||
continue;
|
||||
}
|
||||
|
||||
current_request.encrypt(cfg_.encryption_token);
|
||||
try {
|
||||
auto current_request = base_request;
|
||||
current_request.encode_top(current_client->nonce);
|
||||
request = current_request;
|
||||
|
||||
write_all_with_deadline(
|
||||
io_context_, current_client->socket,
|
||||
boost::asio::buffer(¤t_request[0],
|
||||
current_request.get_size()),
|
||||
std::chrono::milliseconds(cfg_.send_timeout_ms));
|
||||
current_request.encrypt(cfg_.encryption_token);
|
||||
|
||||
ret = read_packet(*current_client, response);
|
||||
write_all_with_deadline(
|
||||
io_context_, current_client->socket,
|
||||
boost::asio::buffer(¤t_request[0], current_request.get_size()),
|
||||
std::chrono::milliseconds(cfg_.send_timeout_ms));
|
||||
|
||||
ret = read_packet(*current_client, response);
|
||||
if (ret == 0) {
|
||||
ret = response.decode(service_flags);
|
||||
if (ret == 0) {
|
||||
ret = response.decode(service_flags);
|
||||
packet::error_type res{};
|
||||
ret = response.decode(res);
|
||||
if (ret == 0) {
|
||||
packet::error_type res{};
|
||||
ret = response.decode(res);
|
||||
if (ret == 0) {
|
||||
ret = res;
|
||||
success = true;
|
||||
put_client(current_client);
|
||||
continue;
|
||||
}
|
||||
ret = res;
|
||||
success = true;
|
||||
put_client(current_client);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::raise_error(function_name, e, "send failed");
|
||||
close(*current_client);
|
||||
retry_after_sleep();
|
||||
}
|
||||
} else {
|
||||
} catch (const std::exception &e) {
|
||||
utils::error::raise_error(function_name, e, "send failed");
|
||||
close(*current_client);
|
||||
retry_after_sleep();
|
||||
}
|
||||
}
|
||||
|
||||
if (not allow_connections_) {
|
||||
ret = utils::from_api_error(api_error::error);
|
||||
success = true;
|
||||
}
|
||||
if (not allow_connections_) {
|
||||
ret = utils::from_api_error(api_error::error);
|
||||
}
|
||||
|
||||
return CONVERT_STATUS_NOT_IMPLEMENTED(ret);
|
||||
|
Reference in New Issue
Block a user