diff --git a/pyrogram/connection/connection.py b/pyrogram/connection/connection.py index 429d5520..92f8389a 100644 --- a/pyrogram/connection/connection.py +++ b/pyrogram/connection/connection.py @@ -56,7 +56,7 @@ class Connection: def send(self, data: bytes): with self.lock: - self.connection.send(data) + self.connection.sendall(data) def recv(self) -> bytes or None: - return self.connection.recv() + return self.connection.recvall() diff --git a/pyrogram/connection/transport/tcp/tcp.py b/pyrogram/connection/transport/tcp/tcp.py index 11990202..4528a281 100644 --- a/pyrogram/connection/transport/tcp/tcp.py +++ b/pyrogram/connection/transport/tcp/tcp.py @@ -28,12 +28,6 @@ class TCP(socks.socksocket): def __init__(self): super().__init__() - def send(self, *args): - pass - - def recv(self, *args): - pass - def close(self): try: self.shutdown(socket.SHUT_RDWR) diff --git a/pyrogram/connection/transport/tcp/tcp_abridged.py b/pyrogram/connection/transport/tcp/tcp_abridged.py index 33b4a507..532c1875 100644 --- a/pyrogram/connection/transport/tcp/tcp_abridged.py +++ b/pyrogram/connection/transport/tcp/tcp_abridged.py @@ -33,7 +33,7 @@ class TCPAbridged(TCP): self.is_first_packet = True log.info("Connected!") - def send(self, data: bytes): + def sendall(self, data: bytes, *args): length = len(data) // 4 data = ( @@ -48,20 +48,20 @@ class TCPAbridged(TCP): super().sendall(data) - def recv(self) -> bytes or None: - length = self.recvall(1) + def recvall(self, length: int = 0) -> bytes or None: + length = super().recvall(1) if length is None: return None if length == b"\x7f": - length = self.recvall(3) + length = super().recvall(3) if length is None: return None length = int.from_bytes(length, "little") * 4 - packet = self.recvall(length) + packet = super().recvall(length) return packet diff --git a/pyrogram/connection/transport/tcp/tcp_full.py b/pyrogram/connection/transport/tcp/tcp_full.py index 8b932eee..d25905b1 100644 --- a/pyrogram/connection/transport/tcp/tcp_full.py +++ b/pyrogram/connection/transport/tcp/tcp_full.py @@ -35,7 +35,7 @@ class TCPFull(TCP): self.seq_no = 0 log.info("Connected!") - def send(self, data: bytes): + def sendall(self, data: bytes, *args): # 12 = packet_length (4), seq_no (4), crc32 (4) (at the end) data = pack(" bytes or None: - length = self.recvall(4) + def recvall(self, length: int = 0) -> bytes or None: + length = super().recvall(4) if length is None: return None - packet = self.recvall(unpack(" bytes or None: - length = self.recvall(4) + def recvall(self, length: int = 0) -> bytes or None: + length = super().recvall(4) if length is None: return None - packet = self.recvall(unpack("