Set a known buffer size if possible on BinaryWriter()s

This commit is contained in:
Lonami Exo
2017-08-29 20:25:49 +02:00
parent 7ad2ece168
commit b4811261e9
4 changed files with 15 additions and 9 deletions

View File

@@ -20,7 +20,7 @@ class MtProtoPlainSender:
def send(self, data):
"""Sends a plain packet (auth_key_id = 0) containing the given message body (data)"""
with BinaryWriter() as writer:
with BinaryWriter(known_length=len(data) + 20) as writer:
writer.write_long(0)
writer.write_long(self._get_new_msg_id())
writer.write_int(len(data))