mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 12:59:46 +00:00
Support custom event loops
This commit is contained in:
@@ -13,10 +13,12 @@ class ConnectionTcpFull(Connection):
|
||||
Default Telegram mode. Sends 12 additional bytes and
|
||||
needs to calculate the CRC value of the packet itself.
|
||||
"""
|
||||
def __init__(self, proxy=None, timeout=timedelta(seconds=5)):
|
||||
super().__init__(proxy, timeout)
|
||||
def __init__(self, *, loop, proxy=None, timeout=timedelta(seconds=5)):
|
||||
super().__init__(loop=loop, proxy=proxy, timeout=timeout)
|
||||
self._send_counter = 0
|
||||
self.conn = TcpClient(proxy=self._proxy, timeout=self._timeout)
|
||||
self.conn = TcpClient(
|
||||
proxy=self._proxy, timeout=self._timeout, loop=self._loop
|
||||
)
|
||||
self.read = self.conn.read
|
||||
self.write = self.conn.write
|
||||
|
||||
@@ -40,9 +42,6 @@ class ConnectionTcpFull(Connection):
|
||||
async def close(self):
|
||||
self.conn.close()
|
||||
|
||||
def clone(self):
|
||||
return ConnectionTcpFull(self._proxy, self._timeout)
|
||||
|
||||
async def recv(self):
|
||||
packet_len_seq = await self.read(8) # 4 and 4
|
||||
packet_len, seq = struct.unpack('<ii', packet_len_seq)
|
||||
|
Reference in New Issue
Block a user