corda / net.corda.core.flows / FlowLogic / sendAndReceive

# sendAndReceive

`inline fun <reified R : Any> sendAndReceive(otherParty: Party, payload: Any): UntrustworthyData<R>`

Serializes and queues the given payload object for sending to the otherParty. 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.

Returns
an UntrustworthyData wrapper around the received object.

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

Serializes and queues the given payload object for sending to the otherParty. 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.

Returns
an UntrustworthyData wrapper around the received object.