Stop using BinaryWriter on MtProtoPlainSender

This commit is contained in:
Lonami Exo 2017-09-28 11:43:06 +02:00
parent fe30f63d5d
commit 2fd03e5422

View File

@ -1,7 +1,8 @@
import struct
import time import time
from ..errors import BrokenAuthKeyError from ..errors import BrokenAuthKeyError
from ..extensions import BinaryReader, BinaryWriter from ..extensions import BinaryReader
class MtProtoPlainSender: class MtProtoPlainSender:
@ -25,14 +26,9 @@ class MtProtoPlainSender:
"""Sends a plain packet (auth_key_id = 0) containing the """Sends a plain packet (auth_key_id = 0) containing the
given message body (data) given message body (data)
""" """
with BinaryWriter(known_length=len(data) + 20) as writer: self._connection.send(
writer.write_long(0) struct.pack('<QQi', 0, self._get_new_msg_id(), len(data)) + data
writer.write_long(self._get_new_msg_id()) )
writer.write_int(len(data))
writer.write(data)
packet = writer.get_bytes()
self._connection.send(packet)
def receive(self): def receive(self):
"""Receives a plain packet, returning the body of the response""" """Receives a plain packet, returning the body of the response"""