WAMP Programming Examples
There are several very-similar examples that each follow a similar form and demonstrate several different ways of using WAMP under Autobahn. Each of these examples usually includes:
- backend.py: the logical "backend", in Python (registers procedures, publishes events)
- frontend.py: the logical "frontend", in Python (calls endpoints, receives events)
- *.html: boilerplate to hold the .js
Note that any WAMP component can "do" all the roles (so a "backend" component can easily also call endpoints or listen for events) but we needed to separate things somehow. However, you can organize your components however you see fit.
For examples using RPC, you need to run the backend first, so that procedures are registered and available to call.
The following examples show two alternative ways of connecting a WAMP client to a WAMP router. This code is also a good starting point for own apps.
- LoopingCall: shows an alternative way of publishing periodically
- Arguments: different types of argument-passing
- Complex: complex return types
- Decorators: register RPC methods using decorators
- Errors: map custom error classes to WAMP URIs
- Options: show some RegistrationOptions and CallOptions use
- Progress: progressive results for long-running oprations
- Slow Square: an RPC call that takes some time
- Time Service: XXX delete?
- Basic: publish to a topic once per second
- Complex: demonstrates different payload arguments
- Decorators: doing subscriptions with decorators
- Options: use of PublishOptions and SubscribeOptions
- Unsubscribe: listen to events for a limited time
We still need to explain these. For starters, here's the list:
- Calculator: to be explained...
- Crochet: to be explained...
- DBus: to be explained...
- Hello: to be explained...
- Keyvalue: to be explained...
- Klein: to be explained...
- Serial2ws: to be explained...
- Subscribe upon call: to be explained...