make c++11 happy; avoid asio remote_endpoint exception

This commit is contained in:
qicosmos
2022-01-17 19:15:35 +08:00
parent 998e9dd0c2
commit 987a306092
2 changed files with 8 additions and 3 deletions
+6 -1
View File
@@ -82,7 +82,12 @@ public:
return "";
}
return socket_.remote_endpoint().address().to_string();
asio::error_code ec;
auto endpoint = socket_.remote_endpoint(ec);
if (ec) {
return "";
}
return endpoint.address().to_string();
}
void publish(const std::string &key, const std::string &data) {
+2 -2
View File
@@ -229,7 +229,7 @@ public:
call(const std::string &rpc_name, Args &&...args) {
auto future_result =
async_call<FUTURE>(rpc_name, std::forward<Args>(args)...);
std::shared_ptr<bool> guard(nullptr, [this, &future_result](auto) {
std::shared_ptr<bool> guard(nullptr, [this, &future_result](bool *) {
std::unique_lock<std::mutex> lock(cb_mtx_);
future_map_.erase(future_result.id);
});
@@ -253,7 +253,7 @@ public:
call(const std::string &rpc_name, Args &&...args) {
auto future_result =
async_call<FUTURE>(rpc_name, std::forward<Args>(args)...);
std::shared_ptr<bool> guard(nullptr, [this, &future_result](auto) {
std::shared_ptr<bool> guard(nullptr, [this, &future_result](bool *) {
std::unique_lock<std::mutex> lock(cb_mtx_);
future_map_.erase(future_result.id);
});