Created
June 15, 2015 17:01
-
-
Save oberstet/70901f556271eeceec0e to your computer and use it in GitHub Desktop.
This file contains 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
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