Merge pull request #39 from bradjc/on-reconnect
Make on_reconnect callback functional
This commit is contained in:
commit
ee425459bd
1 changed files with 10 additions and 0 deletions
|
|
@ -29,6 +29,7 @@ class BaseNamespace(object):
|
|||
def __init__(self, _transport, path):
|
||||
self._transport = _transport
|
||||
self.path = path
|
||||
self.was_connected = False
|
||||
self._callback_by_event = {}
|
||||
self.initialize()
|
||||
|
||||
|
|
@ -109,6 +110,15 @@ class BaseNamespace(object):
|
|||
return self._callback_by_event[event]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
# Convert connect to reconnect if we have seen connect
|
||||
# already.
|
||||
if event == 'connect':
|
||||
if self.was_connected == False:
|
||||
self.was_connected = True
|
||||
else:
|
||||
event = 'reconnect'
|
||||
|
||||
# Check callbacks defined explicitly or use on_event()
|
||||
return getattr(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue