Handle server pongs for manual ping requests

This commit is contained in:
Lonami Exo 2017-01-19 15:54:28 +01:00
parent 9ca4471bcd
commit 78fe053ff3

View File

@ -198,6 +198,8 @@ class MtProtoSender:
if code == 0xf35c6d01: # rpc_result, (response of an RPC call, i.e., we sent a request) 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) 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 if code == 0x73f1f8dc: # msg_container
return self.handle_container(msg_id, sequence, reader, request) return self.handle_container(msg_id, sequence, reader, request)
if code == 0x3072cfa1: # gzip_packed if code == 0x3072cfa1: # gzip_packed
@ -235,6 +237,15 @@ class MtProtoSender:
return False 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): def handle_container(self, msg_id, sequence, reader, request):
reader.read_int(signed=False) # code reader.read_int(signed=False) # code
size = reader.read_int() size = reader.read_int()