FlowSession.sendAndReceive - corda

corda / net.corda.core.flows / FlowSession / sendAndReceive

# sendAndReceive

`@Suspendable fun <reified R : Any> sendAndReceive(payload: Any): UntrustworthyData<R>`

Serializes and queues the given payload object for sending to the counterparty. Suspends until a response is received, which must be of the given R type.

Remember that when receiving data from other parties the data should not be trusted until it's been thoroughly verified for consistency and that all expectations are satisfied, as a malicious peer may send you subtly corrupted data in order to exploit your code.

Note that this function is not just a simple send+receive pair: it is more efficient and more correct to use this when you expect to do a message swap than do use send and then receive in turn.

Return
an UntrustworthyData wrapper around the received object.

`@Suspendable abstract fun <R : Any> sendAndReceive(receiveType: Class<R>, payload: Any, maySkipCheckpoint: Boolean): UntrustworthyData<R>`

Serializes and queues the given payload object for sending to the counterparty. Suspends until a response is received, which must be of the given receiveType. Remember that when receiving data from other parties the data should not be trusted until it's been thoroughly verified for consistency and that all expectations are satisfied, as a malicious peer may send you subtly corrupted data in order to exploit your code.

Note that this function is not just a simple send+receive pair: it is more efficient and more correct to use this when you expect to do a message swap than do use send and then receive in turn.

### Parameters

`maySkipCheckpoint` - setting it to true indicates to the platform that it may optimise away the checkpoint.

Return
an UntrustworthyData wrapper around the received object.

`@Suspendable abstract fun <R : Any> sendAndReceive(receiveType: Class<R>, payload: Any): UntrustworthyData<R>`

Serializes and queues the given payload object for sending to the counterparty. Suspends until a response is received, which must be of the given receiveType. Remember that when receiving data from other parties the data should not be trusted until it's been thoroughly verified for consistency and that all expectations are satisfied, as a malicious peer may send you subtly corrupted data in order to exploit your code.

Note that this function is not just a simple send+receive pair: it is more efficient and more correct to use this when you expect to do a message swap than do use send and then receive in turn.

Return
an UntrustworthyData wrapper around the received object.