From 78fe053ff32b5294b75fe9e539b73995c136a270 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Thu, 19 Jan 2017 15:54:28 +0100 Subject: [PATCH] Handle server pongs for manual ping requests --- telethon/network/mtproto_sender.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/telethon/network/mtproto_sender.py b/telethon/network/mtproto_sender.py index 2b50cf2c..9bc1fb1a 100755 --- a/telethon/network/mtproto_sender.py +++ b/telethon/network/mtproto_sender.py @@ -198,6 +198,8 @@ class MtProtoSender: if code == 0xf35c6d01: # rpc_result, (response of an RPC call, i.e., we sent a request) return self.handle_rpc_result(msg_id, sequence, reader, request) + if code == 0x347773c5: # pong + return self.handle_pong(msg_id, sequence, reader, request) if code == 0x73f1f8dc: # msg_container return self.handle_container(msg_id, sequence, reader, request) if code == 0x3072cfa1: # gzip_packed @@ -235,6 +237,15 @@ class MtProtoSender: return False + def handle_pong(self, msg_id, sequence, reader, request): + reader.read_int(signed=False) # code + recv_msg_id = reader.read_long(signed=False) + + if recv_msg_id == request.msg_id: + request.confirm_received = True + + return False + def handle_container(self, msg_id, sequence, reader, request): reader.read_int(signed=False) # code size = reader.read_int()