Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. from autobahn.asyncio.wamp import ApplicationSession
  2. from autobahn.asyncio.wamp import ApplicationRunner
  3. from asyncio import coroutine
  4.  
  5. class PoloniexComponent(ApplicationSession):
  6. def onConnect(self):
  7. self.join(self.config.realm)
  8.  
  9. @coroutine
  10. def onJoin(self, details):
  11. def onTrollbox(*args):
  12. print("Trollbox Message received:", args)
  13.  
  14. try:
  15. yield from self.subscribe(onTrollbox, 'trollbox')
  16. except Exception as e:
  17. print("Could not subscribe to topic:", e)
  18.  
  19. runner = ApplicationRunner("wss://api.poloniex.com", "realm1")
  20. runner.run(PoloniexComponent)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement