Reputation: 315
I have the following Actor Model declaration in akka:
val wireA = system.actorOf(Props(new Wire(false)), "Input")
val wireB = system.actorOf(Props(new Wire(false)), "Output")
inverter ! generateOutput(wireA, wireB)
From the generateOutput(input:ActorRef, output:ActorRef)
,
I need to access the boolean
parameter which constructs each particularActorRef
(i.e the paramater false
which is found in each respective Wire
Constructor.
How does it can be reached?
Upvotes: 2
Views: 1013
Reputation: 642
It's not the way you should play with Actors. You get the ActorRef and you you play with it only with the messages. You can ask the actor of the value of the boolean by passing a message to it:
wireA ! "getVal"
and waiting for the response in the sender actor. Please check the basic tutorial on Actors:
http://alvinalexander.com/scala/scala-akka-actors-ping-pong-simple-example
Upvotes: 2
Reputation: 7476
You can send a message to each actor, asking for its current status:
case object Status
case object StatusResult(value: Boolean)
class MyActor(wire: ActorRef) extends Actor {
wire ! Status
def receive = {
case StatusResult(value) => ...
}
wireA
and wireB
are ActorRef
s, they do not expose their state and the only way to communicate with them is via messages.
Upvotes: 2