def send_message(self, data):
<EOL>data = asbytes(data)<EOL>cmd = byte_ord(data[<NUM_LIT:0>])<EOL>if cmd in MSG_NAMES:<EOL><INDENT>cmd_name = MSG_NAMES[cmd]<EOL><DEDENT>else:<EOL><INDENT>cmd_name = "<STR_LIT>".format(cmd)<EOL><DEDENT>orig_len = len(data)<EOL>self.__write_lock.acquire()<EOL>try:<EOL><INDENT>if self.__compress_engine_out is not None:<EOL><INDENT>data = self.__compress_engine_out(data)<EOL><DEDENT>packet = self._build_packet(data)<EOL>if self.__dump_packets:<EOL><INDENT>self._log(<EOL>DEBUG,<EOL>"<STR_LIT>".format(cmd_name, orig_len),<EOL>)<EOL>self._log(DEBUG, util.format_binary(packet, "<STR_LIT>"))<EOL><DEDENT>if self.__block_engine_out is not None:<EOL><INDENT>out = self.__block_engine_out.update(packet)<EOL><DEDENT>else:<EOL><INDENT>out = packet<EOL><DEDENT>if self.__block_engine_out is not None:<EOL><INDENT>payload = (<EOL>struct.pack("<STR_LIT>", self.__sequence_number_out) + packet<EOL>)<EOL>out += compute_hmac(<EOL>self.__mac_key_out, payload, self.__mac_engine_out<EOL>)[: self.__mac_size_out]<EOL><DEDENT>self.__sequence_number_out = (<EOL>self.__sequence_number_out + <NUM_LIT:1><EOL>) & xffffffff<EOL>self.write_all(out)<EOL>self.__sent_bytes += len(out)<EOL>self.__sent_packets += <NUM_LIT:1><EOL>sent_too_much = (<EOL>self.__sent_packets >= self.REKEY_PACKETS<EOL>or self.__sent_bytes >= self.REKEY_BYTES<EOL>)<EOL>if sent_too_much and not self.__need_rekey:<EOL><INDENT>msg = "<STR_LIT>"<EOL>self._log(<EOL>DEBUG, msg.format(self.__sent_packets, self.__sent_bytes)<EOL>)<EOL>self.__received_bytes_overflow = <NUM_LIT:0><EOL>self.__received_packets_overflow = <NUM_LIT:0><EOL>self._trigger_rekey()<EOL><DEDENT><DEDENT>finally:<EOL><INDENT>self.__write_lock.release()<EOL><DEDENT>
Write a block of data using the current cipher, as an SSH block.