Skip to content

Instantly share code, notes, and snippets.

@agronholm
Created February 24, 2017 23:22
Show Gist options
  • Save agronholm/566726566c30987ff27bb0daff0329e5 to your computer and use it in GitHub Desktop.
Save agronholm/566726566c30987ff27bb0daff0329e5 to your computer and use it in GitHub Desktop.
Sample WAMP subscriber
# Install asphalt-wamp first:
# pip install git+https://github.com/asphalt-framework/asphalt-wamp.git@932183440a064
from pprint import pprint
from asphalt.core import Context, run_application, ContainerComponent
def handle_event(ctx, event):
pprint(event)
class SubscriberComponent(ContainerComponent):
async def start(self, ctx: Context):
self.add_component('wamp', host='localhost', port=8800, realm='myrealm')
await super().start(ctx)
await ctx.wamp.subscribe(handle_event, 'some.topic')
run_application(SubscriberComponent())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment