"""Producer Module"""import json
from twisted.internet.defer import inlineCallbacks
from autobahn.twisted.wamp import ApplicationSession, ApplicationRunnerfrom autobahn.wamp.types import PublishOptions
from eventify import Eventify
class ProducerApp(ApplicationSession): """ Handle methods for publishing methods to transport """
@inlineCallbacks def onJoin(self, details): print("session joined") topic = self.config.extra['publish_topic']['topic'] pub_options = PublishOptions(**self.config.extra['pub_options']) message = json.dumps({ "event": "UiEventProducerStarted" })
# Publish Service Started yield self.publish( topic, message, options=pub_options )
class Producer(Eventify):
def start(self): """ Run application """
# Configure application runner = ApplicationRunner( url=self.config['transport_host'], realm=u"realm1", extra=self.config )
# Start event loop runner.run( ProducerApp, auto_reconnect=True )
from eventify.producer import Producer
if __name__ == '__main__': """ Start the producer service """ print('Starting UI event message producer...') producer = Producer(config_file='config.json') producer.start()
from eventify.producer import Producer
if __name__ == '__main__': """ Start the producer service """ print('Starting UI event message producer...') producer = Producer(config_file='config.json') producer.start()
# Send event to crossbar
producer.publish("some event happened")
--
You received this message because you are subscribed to the Google Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send an email to autobahnws+...@googlegroups.com.
To post to this group, send email to autob...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/17c94e0a-258e-4db8-8b3c-41c5b32850f2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/b229bbc1-dc8d-49f8-8e97-4f5870956f11%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "Autobahn" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/autobahnws/4tgOgzHCWBM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to autobahnws+...@googlegroups.com.
To post to this group, send email to autob...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/CAFZ8Xq6imqZqe5ReTd4mq0ZvwGOjodCFV%3DSH%2B59OdnR%2BVmELBQ%40mail.gmail.com.