mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Send getState upon successful reconnection
This commit is contained in:
@@ -42,7 +42,7 @@ class MTProtoSender:
|
||||
"""
|
||||
def __init__(self, state, connection, loop, *,
|
||||
retries=5, auto_reconnect=True, update_callback=None,
|
||||
auth_key_callback=None):
|
||||
auth_key_callback=None, auto_reconnect_callback=None):
|
||||
self.state = state
|
||||
self._connection = connection
|
||||
self._loop = loop
|
||||
@@ -52,6 +52,7 @@ class MTProtoSender:
|
||||
self._auto_reconnect = auto_reconnect
|
||||
self._update_callback = update_callback
|
||||
self._auth_key_callback = auth_key_callback
|
||||
self._auto_reconnect_callback = auto_reconnect_callback
|
||||
|
||||
# Whether the user has explicitly connected or disconnected.
|
||||
#
|
||||
@@ -307,6 +308,9 @@ class MTProtoSender:
|
||||
for m in self._pending_messages.values():
|
||||
self._send_queue.put_nowait(m)
|
||||
|
||||
if self._auto_reconnect_callback:
|
||||
self._loop.create_task(self._auto_reconnect_callback())
|
||||
|
||||
break
|
||||
except ConnectionError:
|
||||
__log__.info('Failed reconnection retry %d/%d', retry, retries)
|
||||
|
Reference in New Issue
Block a user