Files
deb-python-autobahn/examples/twisted/wamp/basic
2014-07-27 20:25:21 +02:00
..
2014-06-21 19:12:38 +02:00
2014-04-13 21:26:13 +02:00
2014-06-21 21:00:59 +02:00

WAMP Programming Examples

Examples

  1. RPC
  1. PubSub

How to run

To run the following examples, you need a WAMP router.

For example, you can use the included basic WAMP router by doing

python basicrouter.py

Or you can use Crossbar.io:

mkdir mynode
cd mynode
crossbar init
crossbar start

The examples usually contain two components:

  • frontend
  • backend

Each component is provided in two languages:

  • Python
  • JavaScript

The JavaScript version can run on the browser or in NodeJS.

To run an example, you can have three terminal sessions open with:

  1. router
  2. frontend
  3. backend

E.g. the Python examples can be run

cd pubsub/basic
python backend.py

Hosting

Crossbar.io is a WAMP router that can also act as a host for WAMP application components. E.g. to let Crossbar.io host a backend application component, you can use a node configuration like this:


{
   "controller": {
   },
   "workers": [
      {
         "type": "router",
         "options": {
            "pythonpath": ["f:\\scm\\tavendo\\autobahn\\AutobahnPython\\examples\\twisted\\wamp\\basic"]
         },
         "realms": [
            {
               "name": "realm1",
               "roles": [
                  {
                     "name": "anonymous",
                     "permissions": [
                        {
                           "uri": "*",
                           "publish": true,
                           "subscribe": true,
                           "call": true,
                           "register": true
                        }
                     ]
                  }
               ]
            }
         ],
         "components": [
            {
               "type": "class",
               "classname": "pubsub.complex.backend.Component",
               "realm": "realm1"
            }
         ],
         "transports": [
            {
               "type": "web",
               "endpoint": {
                  "type": "tcp",
                  "port": 8080
               },
               "paths": {
                  "/": {
                     "type": "static",
                     "directory": ".."
                  },
                  "ws": {
                     "type": "websocket"
                  }
               }
            }
         ]
      }
   ]
}