Commit 8cb6b747 authored by Dominik Charousset's avatar Dominik Charousset

Simplify openssl::remote_actor

parent 7f577f42
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "caf/sec.hpp" #include "caf/sec.hpp"
#include "caf/atom.hpp" #include "caf/atom.hpp"
#include "caf/expected.hpp" #include "caf/expected.hpp"
#include "caf/scoped_actor.hpp" #include "caf/function_view.hpp"
#include "caf/openssl/manager.hpp" #include "caf/openssl/manager.hpp"
...@@ -39,27 +39,18 @@ expected<strong_actor_ptr> remote_actor(actor_system& sys, ...@@ -39,27 +39,18 @@ expected<strong_actor_ptr> remote_actor(actor_system& sys,
std::string host, uint16_t port) { std::string host, uint16_t port) {
CAF_LOG_TRACE(CAF_ARG(mpi) << CAF_ARG(host) << CAF_ARG(port)); CAF_LOG_TRACE(CAF_ARG(mpi) << CAF_ARG(host) << CAF_ARG(port));
expected<strong_actor_ptr> res{strong_actor_ptr{nullptr}}; expected<strong_actor_ptr> res{strong_actor_ptr{nullptr}};
scoped_actor self{sys}; auto f = make_function_view(sys.openssl_manager().actor_handle());
auto mm = sys.openssl_manager().actor_handle(); auto x = f(connect_atom::value, std::move(host), port);
CAF_ASSERT(mm != nullptr); if (!x)
self->request(sys.openssl_manager().actor_handle(), infinite, return std::move(x.error());
connect_atom::value, std::move(host), port) auto& tup = *x;
.receive( auto& ptr = get<1>(tup);
[&](const node_id&, strong_actor_ptr& ptr, std::set<std::string>& found) { if (!ptr)
if (ptr) { return sec::no_actor_published_at_port;
if (sys.assignable(found, mpi)) auto& found_mpi = get<2>(tup);
res = std::move(ptr); if (sys.assignable(found_mpi, mpi))
else return std::move(ptr);
res = sec::unexpected_actor_messaging_interface; return sec::unexpected_actor_messaging_interface;
} else {
res = sec::no_actor_published_at_port;
}
},
[&](error& err) {
res = std::move(err);
}
);
return res;
} }
} // namespace openssl } // namespace openssl
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment