Example #1
0
void unpublish_impl(const actor_addr& whom, uint16_t port, bool blocking) {
  CAF_LOGF_TRACE(CAF_TSARG(whom) << ", " << CAF_ARG(port) << CAF_ARG(blocking));
  auto mm = get_middleman_actor();
  if (blocking) {
    scoped_actor self;
    self->sync_send(mm, unpublish_atom::value, whom, port).await(
      [](ok_atom) {
        // ok, basp_broker is done
      },
      [](error_atom, const std::string&) {
        // ok, basp_broker is done
      }
    );
  } else {
    anon_send(mm, unpublish_atom::value, whom, port);
  }
}
Example #2
0
actor_addr remote_actor_impl(std::set<std::string> ifs,
                             std::string host, uint16_t port) {
  auto mm = get_middleman_actor();
  actor_addr result;
  scoped_actor self;
  self->sync_send(mm, connect_atom::value, std::move(host), port).await(
    [&](ok_atom, const node_id&, actor_addr res, std::set<std::string>& xs) {
      if (!res)
        throw network_error("no actor published at given port");
      if (! (xs.empty() && ifs.empty())
          && ! std::includes(xs.begin(), xs.end(), ifs.begin(), ifs.end()))
        throw network_error("expected signature does not "
                            "comply to found signature");
      result = std::move(res);
    },
    [&](error_atom, std::string& msg) {
      throw network_error(std::move(msg));
    }
  );
  return result;
}