Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
_static/img
Doxyfile
README.md
building.rst
examples.md
gettingstarted.md
reference.md
spelling_wordlist.txt

README.md

Autobahn|CPP Documentation

This documentation is quite outdated (and also woefully incomplete). When in doubt ask on the mailing list or read the code!

Contributions to this documentation are highly welcome!

Autobahn|CPP is an open-source networking library for C++ created by the Autobahn project that implements the Web Application Messaging Protocol (WAMP) for creating C++ components communicating with a WAMP router via Unix pipes.

Web Application Messaging Protocol (WAMP)

WAMP is ideal for distributed, multi-client and server applications, such as multi-user database-drive business applications, sensor networks (IoT), instant messaging or MMOGs (massively multi-player online games) .

WAMP enables application architectures with application code distributed freely across processes and devices according to functional aspects. Since WAMP implementations exist for multiple languages, WAMP applications can be polyglot. Application components can be implemented in a language and run on a device which best fit the particular use case.

To enable this, WAMP implements both the Remote Procedure Call (RPC) and and the Publish and Subscribe (PubSub) messaging pattern.

|ab| supports the following application roles:

  • Caller
  • Callee
  • Publisher
  • Subscriber

Show me some code!

Here is what programming with C++ and |ab| looks like.

Calling a remote Procedure

auto c1 = session.call("com.mathservice.add2", {23, 777})
.then(
   [&](future<any> f) {
      cout << "Got call result " << any_cast<uint64_t> (f.get()) << endl;
   });

Registering a remoted Procedure

auto r1 = session.provide("com.myapp.cpp.square",
   [](const anyvec& args, const anymap& kwargs) {
      cout << "Procedure is invoked .." << endl;
      uint64_t x = any_cast<uint64_t> (args[0]);
      return x * x;
   })
.then(
   [](future<registration> reg) {
      cout << "Registered with ID " << reg.get().id << endl;
   });

Publishing an Event

session.publish("com.myapp.topic2", {23, true, string("hello")});

Publishing an Event (acknowledged)

auto opts = PublishOptions();
opts.acknowledge = True;

auto p1 = session.publish("com.myapp.topic2", {23, true, string("hello")}, opts)
.then(
   [](future<publication> pub) {
      cout << "Published with ID " << pub.get().id << endl;
   });

Subscribing to a Topic

auto s1 = session.subscribe("com.myapp.topic1",
   [](const anyvec& args, const anymap& kwargs) {
      cout << "Got event: " << any_cast<uint64_t>(args[0]) << endl;
   })
.then(
   [](future<subscription> sub) {
      cout << "Subscribed with ID " << sub.get().id << endl;
   });

Here is JavaScript running in Chrome call into C++ running on command line. Both are connected via a WAMP router, in this case Autobahn|Python <http://autobahn.ws/python>_ based.

image of chrome dev tools

Download

To get Autobahn|CPP library and examples, clone the repo

shell
cd $HOME
git clone git@github.com:crossbario/autobahn-cpp.git
cd AutobahnCpp

The library is "header-only", means there isn't anything to compile or build. Just include the relevant headers.

Technology

The API and implementation make use of modern C++ 11 and new asynchronous idioms using (upcoming) features of the standard C++ library, in particular Futures, Continuations and Lambdas.

Continuations are one way of managing control flow in an asynchronous program. Other styles include: asynchronous Callbacks, Coroutines (yield or await), Actors (Erlang/OTP, Scala, Akka or Rust) and Transactional memory.

Autobahn|CPP supports running WAMP (rawsocket-msgpack) over TCP(-TLS), Unix domain sockets or pipes (stdio). The library is "header-only", light-weight (< 2k code lines) and depends on the following:

Get in touch

Get in touch on IRC #autobahn on chat.freenode.net, follow us on Twitter or join the mailing list

Resources