def METHOD_NAME(self, message):
    if type(message) is HandshakeRequestMessage:
        content = json.dumps(message.__dict__)
        return content + self.record_separator
    msg = self._encode_message(message)
    encoded_message = msgpack.packb(msg)
    varint_length = self._to_varint(len(encoded_message))
    return varint_length + encoded_message