Skip to content Skip to sidebar Skip to footer

Can Autobahn.twisted.wamp.application Do Pub/sub?

I would like to use some pub/sub features along with rpc from autobahn.twisted.wamp.Application I'd prefer not to make a ApplicationSession class if I can get by without doing so.

Solution 1:

Yes, sure:

defonEvent(msg):
   print("got event: {}".format(msg))

@app.register('com.example.triggersubscribe')deftriggerSubscribe():
   yield app.session.subscribe(onEvent, 'com.example.topic1')

When triggerSubscribe is called (e.g. remotely from another WAMP component), the callee (the WAMP component exposing com.example.triggersubscribe) will dynamically subscribe to com.example.topic1.

You can publish from within a registered procedure also of course: app.session.publish().

I have added the complete example (including JS client) here.

Post a Comment for "Can Autobahn.twisted.wamp.application Do Pub/sub?"