Note that there are some explanatory texts on larger screens.

plurals
  1. POMix normal method calls with messages when using Actors?
    text
    copied!<p>I'm writing a comet application in lift and some of my actors have references to other actors, eg user A has actor B which has a variable storing actor C which is associated with user D.</p> <p>Some user actions by A should result in their actor B sending a message to actor C.</p> <p>These things are triggered by user A.</p> <p>My question is, is it ok to call regular methods on the actor B which result in it sending a message to C, or should I instead be sending a message to A which it receives and then sends the message to B.</p> <p>To put it in code, is this kind of thing ok:</p> <pre><code>//in some snippet: val actorB: ActorB = session.map(.findCometActor(...)) "#some-button" #&gt; SHtml.ajaxInvoke(() =&gt; actorB.sendIt(777)) //is this ok? //the actors: case class MyMessage(someInt: Int, someString: String) class ActorB extends CometActor { private var someString = "" private var otherActor: Box[CometActor] = Empty def sendIt(someInt: Int) = otherActor ! MyMessage(someInt, someString) } class ActorC extends CometActor { def lowPriority = { case MyMessage(num, str) =&gt; println(num + str) } } </code></pre> <p>Or should the snippet code be sending a message to actor B which will then send a message to actor C rather than calling <code>actorB.sendIt(777)</code> directly?</p> <p><strong>Edit</strong>: Just to confirm, there are no technical problems with doing this, it is more about style and hopefully making it easier to make the code correct. Is that right?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload