-
Notifications
You must be signed in to change notification settings - Fork 3
Using Behaviors
ARn edited this page Apr 20, 2016
·
1 revision
####Behaviors
Once created, an actor at message reception can :
- send a message to other actors he knows about
- create other actors
- change its own behavior
To change an actor behavior, you could :
- use the Become statement, all previous behaviors are cleared and replace by the new one
- use the AddBehavior statement, adding a new behavior to the list of existing behaviors.
Here a small sample of usage for the Become statement ...
Become(new ActionBehavior());
It means : "this actor will now answer to Action Message".
And here an example for AddBehavior statement ...
AddBehavior(new ConsoleBehavior<string>());
AddBehavior(new ConsoleStringListbehavior());
AddBehavior(new ConsoleDictionaryBehavior());
AddBehavior(new ConsoleBehavior<int>());
this one comes from the ActorConsole.