core.protocols / ProtocolStateMachine

ProtocolStateMachine

class 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.





Constructors

<init> ProtocolStateMachine(logic: ProtocolLogic<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.

Properties

logger lateinit var logger: <ERROR CLASS>
logic val logic: ProtocolLogic<R>
resultFuture val resultFuture: <ERROR CLASS><R>

This future will complete when the call method returns.

serviceHub lateinit var serviceHub: ServiceHub

Functions

prepareForResumeWith fun prepareForResumeWith(serviceHub: ServiceHub, withObject: Any?, logger: <ERROR CLASS>, suspendFunc: (FiberRequest, ByteArray) -> Unit): Unit
receive fun <T : Any> receive(topic: String, sessionIDForReceive: Long, recvType: Class<T>): UntrustworthyData<T>
run fun run(): R
send fun send(topic: String, destination: MessageRecipients, sessionID: Long, obj: Any): Unit
sendAndReceive fun <T : Any> sendAndReceive(topic: String, destination: MessageRecipients, sessionIDForSend: Long, sessionIDForReceive: Long, obj: Any, recvType: Class<T>): UntrustworthyData<T>