com.r3corda.core.protocols / ProtocolStateMachine

# ProtocolStateMachine

`interface ProtocolStateMachine<R>`

A ProtocolStateMachine instance is a suspendable fiber that delegates all actual logic to a ProtocolLogic instance. For any given flow there is only one PSM, even if that protocol invokes subprotocols.

These classes are created by the StateMachineManager when a new protocol is started at the topmost level. If a protocol invokes a sub-protocol, then it will pass along the PSM to the child. The call method of the topmost logic element gets to return the value that the entire state machine resolves to.

### Properties

id | `abstract val id: StateMachineRunId` Unique ID for this machine run, valid across restarts
logger | `abstract val logger: <ERROR CLASS>`
resultFuture | `abstract val resultFuture: <ERROR CLASS><R>` This future will complete when the call method returns.
serviceHub | `abstract val serviceHub: ServiceHub`

### Functions

receive | `abstract fun <T : Any> receive(otherParty: Party, receiveType: Class<T>, sessionProtocol: ProtocolLogic<*>): UntrustworthyData<T>`
send | `abstract fun send(otherParty: Party, payload: Any, sessionProtocol: ProtocolLogic<*>): Unit`
sendAndReceive | `abstract fun <T : Any> sendAndReceive(otherParty: Party, payload: Any, receiveType: Class<T>, sessionProtocol: ProtocolLogic<*>): UntrustworthyData<T>`

### Inheritors

ProtocolStateMachineImpl | `class ProtocolStateMachineImpl<R> : ProtocolStateMachine<R>`