sendAndReceive

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

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

Note that this function is not just a simple send and receive pair. It is more efficient and more correct to use sendAndReceive when you expect to do a message swap rather than use send and then receive.

Both the payload object and the receiveType should be of a type that is annotated with @CordaSerializable or a primitive type. This function cannot handle types that do not meet these criteria.

Return

The received data

Parameters

<R>

The data type received from the counterparty.

receiveType

The data type received from the counterparty.

payload

The data sent to the counterparty, which should be either a primitive type or a type annotated with @CordaSerializable.

Throws

CordaRuntimeException

if the session is closed or in a failed state.