--(rst-client-begin)--
| 149 | |
| 150 | // --(rst-client-begin)-- |
| 151 | void client(actor_system& sys, const config& cfg) { |
| 152 | auto host = get_or(cfg, "host", default_host); |
| 153 | auto port = get_or(cfg, "port", default_port); |
| 154 | auto node = sys.middleman().connect(host, port); |
| 155 | if (!node) { |
| 156 | sys.println("*** connect failed: {}", node.error()); |
| 157 | return; |
| 158 | } |
| 159 | auto type = "calculator"; // type of the actor we wish to spawn |
| 160 | auto args = make_message(); // arguments to construct the actor |
| 161 | auto tout = std::chrono::seconds(30); // wait no longer than 30s |
| 162 | auto worker = sys.middleman().remote_spawn<calculator>(*node, type, args, |
| 163 | tout); |
| 164 | if (!worker) { |
| 165 | sys.println("*** remote spawn failed: {}", worker.error()); |
| 166 | return; |
| 167 | } |
| 168 | // start using worker in main loop |
| 169 | client_repl(sys, *worker); |
| 170 | // be a good citizen and terminate remotely spawned actor before exiting |
| 171 | anon_send_exit(*worker, exit_reason::kill); |
| 172 | } |
| 173 | // --(rst-client-end)-- |
| 174 | |
| 175 | void caf_main(actor_system& sys, const config& cfg) { |
nothing calls this directly
no test coverage detected