Autobahn Libraries
The Autobahn project is maintained by the same people who created the open source Crossbar.io WAMP router.
It provides open-source implementations of the Web Application Messaging Protocol (WAMP) for a range of languages (as well as the industry-standard WebSocket test suite).
WAMP connects components in distributed applications using Publish and Subscribe (PubSub) and routed Remote Procedure Calls (rRPC). It is ideal for distributed, multi-client and server applications such as IoT applications or multi-user database-driven business applications.
You can contact us via
- our forum
- IRC: freenode, channel `autobahn`
There are also numerous third-party implementations of WAMP clients - see Supported Languages.
Show me some code! ΒΆ
Here is what application components look like in the languages supported by Autobahn:
// 1) SUBSCRIBE to a topic to receive events
function onhello(args) {
console.log("Got event:", args[0]);
}
session.subscribe('com.myapp.hello', onhello);
// 2) PUBLISH an event
session.publish('com.myapp.hello', ['Hello, world!']);
// 3) REGISTER a procedure for remote calling
function add2(args) {
return args[0] + args[1];
}
session.register('com.myapp.add2', add2);
// 4) CALL a remote procedure
session.call('com.myapp.add2', [2, 3]).then(
function (result) {
console.log("Got result:", result);
}
);
# 1) SUBSCRIBE to a topic to receive events
def onhello(msg):
print("Got event: {}".format(msg))
session.subscribe(onhello, 'com.myapp.hello')
# 2) PUBLISH an event
session.publish('com.myapp.hello', 'Hello, world!')
# 3) REGISTER a procedure for remote calling
def add2(x, y):
return x + y
session.register(add2, 'com.myapp.add2');
# 4) CALL a remote procedure
result = yield from session.call('com.myapp.add2', 2, 3)
print("Got result: {}".format(result))
// 1) SUBSCRIBE to a topic to receive events
void onhello(const anyvec& args, const anymap& kwargs) {
cout << "Got event: " << any_cast<string>(args[0]) << endl;
}
session.subscribe("com.myapp.hello", &onhello);
// 2) PUBLISH an event
session.publish("com.myapp.hello", {string("Hello, world!")});
// 3) REGISTER a procedure for remote calling
any add2(const anyvec& args, const anymap& kwargs) {
return any_cast<uint64_t>(args[0]) + any_cast<uint64_t>(args[1]);
}
session.provide("com.myapp.add2", &add2);
// 4) CALL a remote procedure
session.call("com.mathservice.add2", {2, 3}).then(
[&](future<any> f) {
cout << "Got result: " << any_cast<uint64_t> (f.get()) << endl;
}
);