Created
February 24, 2017 23:22
-
-
Save agronholm/566726566c30987ff27bb0daff0329e5 to your computer and use it in GitHub Desktop.
Sample WAMP subscriber
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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