send

suspend fun send(remote: DeviceAddress, plaintext: ByteArray): SentMessage

Sends plaintext to remote as a new logical message and returns its LogicalMessageId and the envelope of this first attempt. Starts a session if there is none. Bodies larger than SecurePayloadCodec.MAX_BODY_SIZE are rejected with ProtocolException.MessageTooLarge.

The message is stored as pending (with its plaintext, see docs/message-reliability.md) in the same transaction as the ratchet step that encrypts it; the envelope is handed to the transport after the commit. It stays pending until remote acknowledges it; a successful hand-off does not remove it. Use retryPendingMessages to send pending messages again, abandonPendingMessage to give one up.

Failures: an exception other than SecureMessageClientException.MessageNotSent means nothing was stored. SecureMessageClientException.MessageNotSent means the message is pending but the transport did not take the envelope; its cause is the transport's exception.

Sends of this client run one at a time, so envelopes reach the transport in encryption order (docs/transport-ordering.md).