RolePlayingAutomaton

scroll.internal.rpa.RolePlayingAutomaton
See theRolePlayingAutomaton companion object

Use this trait to implement your own scroll.internal.compartment.impl.Compartment specific role playing automaton. This implementation uses ZIO to run a lightweight, single-threaded event loop.

Remember to call run() when you want to start this automaton in your scroll.internal.compartment.impl.Compartment instance.

This automaton will always start in state scroll.internal.rpa.RolePlayingAutomaton.Start, so hook in there.

Final state is always scroll.internal.rpa.RolePlayingAutomaton.Stop, which terminates the internal loop.

Use the factory method RolePlayingAutomaton.Use to gain an instance of your specific FSM, e.g.:

trait MyCompartment extends Compartment {
// ... some roles and interaction

// your specific RPA here
class MyRolePlayingAutomaton extends RolePlayingAutomaton {
// specific behavior here
when(Start) {
// ...
}

onTransition {
// ...
}

run()
}

Use[MyRolePlayingAutomaton] For this
}

// start everything
new MyCompartment {}

Some predefined event types for messaging are available in the companion object. You may want to define your own states and event types. Simply use a companion object for this as well.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def goto(state: RPAState, data: RPAData = ...): Transition
def halt(): Unit

Stops this automaton by interrupting the processing fiber.

Stops this automaton by interrupting the processing fiber.

Attributes

Register transition handler. Multiple handlers can be chained.

Register transition handler. Multiple handlers can be chained.

Attributes

def run(): Unit

Starts this automaton. Needs to be called first! Will set the initial state to scroll.internal.rpa.RolePlayingAutomaton.Start.

Starts this automaton. Needs to be called first! Will set the initial state to scroll.internal.rpa.RolePlayingAutomaton.Start.

Attributes

def when(state: RPAState)(handler: PartialFunction[Event, Transition]): Unit

Register event handler for a state.

Register event handler for a state.

Attributes