A wampy Application

This is a fully fledged example of a wampy application that implements all 4 WAMP Roles: caller, callee, publisher and subscriber.

from wampy.peers.clients import Client
from wampy.roles import callee
from wampy.roles import subscriber


class WampyApp(Client):

    @callee
    def get_weather(self, *args, **kwargs):
        weather = self.call("another.example.app.endpoint")
        return weather

    @subscriber(topic="global-weather")
    def weather_events(self, weather_data):
        # process weather data here
        self.publish(topic="wampy-weather", message=weather_data)

Here the method decorated by @callee is a callable remote procedure. In this example, it also acts as a Caller, by calling another remote procedure and then returning the result.

And the method decorated by @subscribe implements the Subscriber Role, and when it receives an Event it then acts as a Publisher, and publishes a new message to a topic.

Note that the call and publish APIs are provided by the super class, Client.

Running The Application

wampy provides a command line interface tool to start the application.

$ wampy run path.to.your.module.including.module_name:WampyApp

For example, running one of the wampy example applications.

$ wampy run docs.examples.services:BinaryNumberService --config './wampy/testing/configs/crossbar.config.ipv4.json'