Title pretty much says it all. I want to invoke an Action in an Actor class from a non-Actor class that is not in the same folder as the Actor if that is possible.
In the actor model, you don't "invoke an action" on the actor. You can ask for something or tell it something.
To do that, you need the actor's address, in akka.net you need an IActorRef
.
I'm not sure what you mean by "folder", I'll just enumerate the possible meanings and the answer to each :
To be able to send a message to an actor you only need it's IActorRef
, there are multiple ways to manage those references that I'm not going write here because it depends on your application architecture.
I will, however, mention that you can also use the ActorSystem.ActorSelection
method to obtain the reference of an actor that's located at a certain path, but this is not recommended because it may easily be misused and can lead to some bad habits. It's usage should be considered an advanced feature.
Once you got your hand on the actor reference, you then can call the Ask
method from your non-actor class if you expect some result (beware, the result will be wrapped in a Task that you'll have to manage to retrieve the result).
If you don't expect an answer (or if you don't care about the response), you can just call the Tell
method.
You have to pass the message to send to the actor to both of these methods.
Finally, once the actor receives your message, your message will eventually be processed and the actor will then do whatever it was designed to do.
If you haven't done it yet, the bootcamp is a good way to learn the basis of akka.net.