Ejemplo n.º 1
0
    def new(cls, seq_no, mtproto_msg):
        payload = mtproto_msg.get_bytes()
        # print('payload:', payload)
        # print(to_hex(scheme.int32_c(len(payload) + 12).get_bytes()))

        header_and_payload = bytes().join([
            scheme.int32_c(len(payload) + 12).get_bytes(),
            scheme.int32_c(seq_no).get_bytes(), payload
        ])

        crc = scheme.int32_c(crc32(header_and_payload)).get_bytes()

        return cls(header_and_payload + crc)
Ejemplo n.º 2
0
    def new(cls, seq_no, mtproto_msg):
        payload = mtproto_msg.get_bytes()
        # print('payload:', payload)
        # print(to_hex(scheme.int32_c(len(payload) + 12).get_bytes()))

        header_and_payload = bytes().join([
            scheme.int32_c(len(payload) + 12).get_bytes(),
            scheme.int32_c(seq_no).get_bytes(),
            payload
            ])

        crc = scheme.int32_c(crc32(header_and_payload)).get_bytes()

        return cls(header_and_payload + crc)
Ejemplo n.º 3
0
 def buffers(self):
     message_data = self.message_data.buffers()
     message_data_length = scheme.int32_c(
         sum([len(data) for data in message_data]))
     # message_data_length = scheme.int32_c(message_data_length)
     return self.auth_key_id.buffers() + self.message_id.buffers(
     ) + message_data_length.buffers() + message_data
Ejemplo n.º 4
0
 def buffers(self):
     message_data = self.message_data.buffers()
     message_data_length = scheme.int32_c(sum([len(data) for data in message_data]))
     # message_data_length = scheme.int32_c(message_data_length)
     return self.auth_key_id.buffers() + self.message_id.buffers() + message_data_length.buffers() + message_data