NOTE that for all examples you will need to run a router. We develop Crossbar.io and there are other routers available as well. We include a working Crossbar.io configuration in the examples/router/ subdirectory as well as instructions on how to run it.
Overview of Examples¶
Each example typically includes four things:
frontend.py: the Caller or Subscriber, in Python
backend.py: the Callee or Publisher, in Python
So for each example, you start one backend and one frontend component (your choice). You can usually start multiple frontend components with no problem, but will get errors if you start two backends trying to register at the same procedure URI (for example).
Still, you are encouraged to try playing with mixing and matching the frontend and backend components, starting multiple front-ends, etc. to explore Crossbar and Autobahn’s behavior. Often the different examples use similar URIs for procedures and published events, so you can even try mixing between the examples.
Automatically Run All Examples¶
There is a script (
./examples/run-all-examples.py) which runs all the WAMP examples for 5 seconds each, this asciicast shows you how (see comments for how to run it yourself):
Publish & Subscribe (PubSub)¶
Remote Procedure Calls (RPC)¶
- Time Service Twisted - asyncio - A trivial time service - demonstrates basic remote procedure feature.
- Slow Square Twisted - asyncio - Demonstrates procedures which return promises and return asynchronously.
- Arguments Twisted - asyncio - Demonstrates all variants of call arguments.
- Complex Result Twisted - asyncio - Demonstrates complex call results (call results with more than one positional or keyword results).
- Errors Twisted - asyncio - Demonstrates error raising and catching over remote procedures.
- Progressive Results Twisted - asyncio - Demonstrates calling remote procedures that produce progressive results.
- Options Twisted - asyncio - Using options with RPC.
I’m Confused, Just Tell Me What To Run¶
If all that is too many options to consider, you want to do this:
- Open 3 terminals
- In terminal 1, setup and run a local Crossbar in the root of your Autobahn checkout.
- In terminals 2 and 3, go to the root of your Autobahn checkout and activate the virtualenv from step 2 (
- In terminal 2 run
- In terminal 3 run
The above procedure is gone over in this this asciicast: