Remove BinaryWriter dependency on MessageContainer

This commit is contained in:
Lonami Exo 2017-09-27 21:06:01 +02:00
parent 833aeb86eb
commit 8a605f21e6

View File

@ -1,5 +1,6 @@
from . import TLObject, GzipPacked import struct
from ..extensions import BinaryWriter
from . import TLObject
class MessageContainer(TLObject): class MessageContainer(TLObject):
@ -11,14 +12,9 @@ class MessageContainer(TLObject):
self.messages = messages self.messages = messages
def to_bytes(self): def to_bytes(self):
# TODO Change this to delete the on_send from this class return struct.pack(
with BinaryWriter() as writer: '<Ii', MessageContainer.constructor_id, len(self.messages)
writer.write_int(MessageContainer.constructor_id, signed=False) ) + b''.join(m.to_bytes() for m in self.messages)
writer.write_int(len(self.messages))
for m in self.messages:
writer.write(m.to_bytes())
return writer.get_bytes()
@staticmethod @staticmethod
def iter_read(reader): def iter_read(reader):