mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-03-28 05:44:14 +03:00
Keep consistent structure and remove done TODO
This commit is contained in:
parent
acd6025731
commit
7e68274f26
|
@ -21,8 +21,6 @@ except ImportError:
|
||||||
__log__ = logging.getLogger(__name__)
|
__log__ = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# TODO Except asyncio.TimeoutError, ConnectionError, OSError...
|
|
||||||
# ...for connect, write and read (in the upper levels, not here)
|
|
||||||
class TcpClient:
|
class TcpClient:
|
||||||
"""A simple TCP client to ease the work with sockets and proxies."""
|
"""A simple TCP client to ease the work with sockets and proxies."""
|
||||||
def __init__(self, proxy=None, timeout=5):
|
def __init__(self, proxy=None, timeout=5):
|
||||||
|
|
|
@ -250,6 +250,23 @@ class MTProtoSender:
|
||||||
self._reconnecting = False
|
self._reconnecting = False
|
||||||
await self._connect()
|
await self._connect()
|
||||||
|
|
||||||
|
def _clean_containers(self, msg_ids):
|
||||||
|
"""
|
||||||
|
Helper method to clean containers from the pending messages
|
||||||
|
once a wrapped msg_id of them has been acknowledged.
|
||||||
|
|
||||||
|
This is the only way we can resend TLMessage(MessageContainer)
|
||||||
|
on bad notifications and also mark them as received once any
|
||||||
|
of their inner TLMessage is acknowledged.
|
||||||
|
"""
|
||||||
|
for i in reversed(range(len(self._pending_containers))):
|
||||||
|
message = self._pending_containers[i]
|
||||||
|
for msg in message.obj.messages:
|
||||||
|
if msg.msg_id in msg_ids:
|
||||||
|
del self._pending_containers[i]
|
||||||
|
del self._pending_messages[message.msg_id]
|
||||||
|
break
|
||||||
|
|
||||||
# Loops
|
# Loops
|
||||||
|
|
||||||
async def _send_loop(self):
|
async def _send_loop(self):
|
||||||
|
@ -521,23 +538,6 @@ class MTProtoSender:
|
||||||
__log__.debug('Handling new session created')
|
__log__.debug('Handling new session created')
|
||||||
self.state.salt = message.obj.server_salt
|
self.state.salt = message.obj.server_salt
|
||||||
|
|
||||||
def _clean_containers(self, msg_ids):
|
|
||||||
"""
|
|
||||||
Helper method to clean containers from the pending messages
|
|
||||||
once a wrapped msg_id of them has been acknowledged.
|
|
||||||
|
|
||||||
This is the only way we can resend TLMessage(MessageContainer)
|
|
||||||
on bad notifications and also mark them as received once any
|
|
||||||
of their inner TLMessage is acknowledged.
|
|
||||||
"""
|
|
||||||
for i in reversed(range(len(self._pending_containers))):
|
|
||||||
message = self._pending_containers[i]
|
|
||||||
for msg in message.obj.messages:
|
|
||||||
if msg.msg_id in msg_ids:
|
|
||||||
del self._pending_containers[i]
|
|
||||||
del self._pending_messages[message.msg_id]
|
|
||||||
break
|
|
||||||
|
|
||||||
async def _handle_ack(self, message):
|
async def _handle_ack(self, message):
|
||||||
"""
|
"""
|
||||||
Handles a server acknowledge about our messages. Normally
|
Handles a server acknowledge about our messages. Normally
|
||||||
|
|
Loading…
Reference in New Issue
Block a user