• DOCUMENTATION 
  • CODE 
  • PROJECT CHAT 
  • MAILING LIST 
  • COMMERCIAL SUPPORT 
  • RESOURCES 
  • Home
  • Docs
  • FSM (Edit on Github)

Akka.NET Docs

Finite State Machine

For more info see real Akka FSM documentation: http://doc.akka.io/docs/akka/snapshot/scala/fsm.html

public class MyFSM : FSM<int, object>
{
    public MyFSM(ActorRef target)
    {
        Target = target;
        StartWith(0, new object());
        When(0, @event =>
        {
            if (@event.FsmEvent.Equals("tick")) return GoTo(1);
            return null;
        });

        When(1, @event =>
        {
            if (@event.FsmEvent.Equals("tick")) return GoTo(0);
            return null;
        });

        WhenUnhandled(@event =>
        {
            if (@event.FsmEvent.Equals("reply")) return Stay().Replying("reply");
            return null;
        });

        Initialize();
    }

    public IActorRef Target { get; private set; }

    protected override void PreRestart(Exception reason, object message)
    {
        Target.Tell("restarted");
    }
}
 

About Akka.NET

Akka.NET is a port of the popular
Java/Scala framework Akka to .NET.

This is a community driven port and
is not affiliated with Typesafe who
makes the original Java/Scala version.

hi@rogeronazure.om

Recent Tweets

Keep Updated

Subscribe to our Newsletter