Skip to content

Instantly share code, notes, and snippets.

@oberstet
Created June 15, 2015 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oberstet/70901f556271eeceec0e to your computer and use it in GitHub Desktop.
Save oberstet/70901f556271eeceec0e to your computer and use it in GitHub Desktop.
from datetime import datetime
from twisted.internet.defer import inlineCallbacks
from autobahn.wamp.types import PublishOptions
from autobahn.twisted.wamp import ApplicationSession
from autobahn.twisted.wamp import ApplicationRunner
from autobahn.twisted.util import sleep
class MyComponent(ApplicationSession):
@inlineCallbacks
def onJoin(self, details):
print("session ready")
yield self.subscribe(self.run, u"a.topic.name")
while True:
yield self.publish(u"a.topic.name", options=PublishOptions(exclude_me=False))
yield sleep(5)
def run(self):
print("run at {}".format(datetime.now()))
runner = ApplicationRunner(url=u"ws://localhost:8080/ws", realm=u"realm1")
runner.run(MyComponent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment