-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathdemo_embedded_router.cc
47 lines (34 loc) · 1.06 KB
/
demo_embedded_router.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Copyright (c) 2017 Darren Smith
*
* wampcc is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#include "wampcc/wampcc.h"
#include <iostream>
using namespace wampcc;
using namespace std;
int main(int, char**)
{
try {
/* Create the wampcc kernel. */
kernel the_kernel;
/* Create an embedded wamp router. */
wamp_router router(&the_kernel);
/* Accept clients on IPv4 port, without authentication. */
auto fut = router.listen(auth_provider::no_auth_required(), 55555);
if (auto ec = fut.get())
throw runtime_error(ec.message());
/* Provide an RPC named 'greeting' on realm 'default_realm'. */
router.callable("default_realm", "greeting",
[](wamp_router&, wamp_session& caller, call_info info) {
caller.result(info.request_id, {"hello"});
});
/* Suspend main thread */
std::promise<void> forever;
forever.get_future().wait();
} catch (const exception& e) {
cout << e.what() << endl;
return 1;
}
}