Is it needed to have the code for remote scala actor on the server?
I would开发者_JS百科 like to use remote actors, of a nature, not known to the server at it's compile time, so that this actors will be defined on the client side only. Is it possible?
Normally, it's not needed.
Remote actors are accessed through actor proxy, which is irrelevant to specific actor implementation. As long as proper way of working with actors is sending messages (and, thus, avoid calling actor methods directly, which, unfortunately possible with standard Scala actors, but, e.g., impossible in Akka that has separation of actors and actor references) proxy will work for you in the most scenarios.
However, there're some cases, when byte code of the actor is required on the other node. E.g, when you want to serialize the actor with its mail box, and send it for execution to another node.
Quote from The Scala Actors API:
To obtain a remote reference to a remote actor running on machine myMachine, on port 8000, with name 'anActor, use select in the following manner:
val myRemoteActor = select(Node("myMachine", 8000),'anActor)
The actor returned from select has type AbstractActor which provides essentially the same interface as a regular actor, and thus supports the usual message send operations
精彩评论