Move MessageContainer.on_send inside its .to_bytes

This commit is contained in:
Lonami Exo 2017-09-27 13:49:58 +02:00
parent 6df9fc558e
commit 795cb98909

View File

@ -14,7 +14,9 @@ class MessageContainer(TLObject):
self.session = session self.session = session
self.requests = requests self.requests = requests
def on_send(self, writer): def to_bytes(self):
# TODO Change this to delete the on_send from this class
with BinaryWriter() as writer:
writer.write_int(MessageContainer.constructor_id, signed=False) writer.write_int(MessageContainer.constructor_id, signed=False)
writer.write_int(len(self.requests)) writer.write_int(len(self.requests))
for x in self.requests: for x in self.requests:
@ -28,11 +30,6 @@ class MessageContainer(TLObject):
packet = GzipPacked.gzip_if_smaller(x) packet = GzipPacked.gzip_if_smaller(x)
writer.write_int(len(packet)) writer.write_int(len(packet))
writer.write(packet) writer.write(packet)
def to_bytes(self):
# TODO Change this to delete the on_send from this class
with BinaryWriter() as writer:
self.on_send(writer)
return writer.get_bytes() return writer.get_bytes()
@staticmethod @staticmethod