Skip to content

Commit

Permalink
make easier to use
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenjs committed Jul 7, 2017
1 parent 409c2dd commit 5a5cbd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion examples/basic/basic_callee.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ using namespace wampcc;
* wamp dealer. */
void rpc(wamp_invocation& invoke)
{
std::cout << "rpc invoked" << std::endl;
invoke.yield( json_array({"hello", "world"}), {} );
}

Expand Down Expand Up @@ -76,7 +77,7 @@ int main(int argc, char** argv)

/* Session is now open, register an RPC. */

session->provide("greeting", json_object(), rpc);
session->provide("greeting2", json_object(), rpc);

/* Wait until wamp session is closed. */

Expand Down
11 changes: 6 additions & 5 deletions examples/basic/basic_caller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ int main(int argc, char** argv)
{
try
{
if (argc != 3)
throw std::runtime_error("arguments must be: ADDR PORT");
if (argc < 3)
throw std::runtime_error("arguments must be: ADDR PORT RPC_URI (RPC_URI defaults to 'greeting')");
const char* host = argv[1];
int port = std::stoi(argv[2]);

std::string rpc_uri = (argc > 3)? argv[3]:"greeting";
/* Create the wampcc kernel, which provides event and IO threads. */

std::unique_ptr<kernel> the_kernel(new kernel({}, logger::nolog()));
Expand Down Expand Up @@ -70,9 +70,10 @@ int main(int argc, char** argv)

wamp_args call_args;
call_args.args_list = json_array({"hello from basic_caller"});
session->call("greeting", {}, call_args,
[&ready_to_exit](wamp_call_result) {
session->call(rpc_uri, {}, call_args,
[&ready_to_exit](wamp_call_result r) {
try {
std::cout << "rpc result: " << r.args.args_list << std::endl;
ready_to_exit.set_value();
} catch (...) { /* ignore promise already set error */}
});
Expand Down

0 comments on commit 5a5cbd3

Please sign in to comment.