Skip to content

Commit

Permalink
Add on_open() callback
Browse files Browse the repository at this point in the history
  • Loading branch information
rudyryk committed Oct 9, 2016
1 parent 1e618fc commit 560eada
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bachata/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def open_async(self):
if channel:
mc = self.get_messages_center()
mc.add_socket(channel, self)
yield from self.on_open()
else:
io_loop = tornado.ioloop.IOLoop.current()
io_loop.add_callback(self.on_auth_error)
Expand All @@ -54,8 +55,15 @@ def authenticate(self):
"""
return

@asyncio.coroutine
def on_open(self):
"""Is called on connection success.
"""
pass

def on_close(self):
"""Remove handler from messages center."""
"""Is called on connection failure.
"""
self.get_messages_center().del_socket(self.get_channel(), self)

def on_message(self, raw_message):
Expand Down

0 comments on commit 560eada

Please sign in to comment.