Created
October 31, 2016 02:18
-
-
Save stelcheck/d2540767344554a7536c089452c4052e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Conversation do | |
use GenFSM | |
def start_link() do | |
IO.puts "Starting FSM" | |
GenFSM.start_link(__MODULE__, nil) | |
end | |
def hello(pid) do | |
GenFSM.send_event(pid, :hello) | |
end | |
def init(nil) do | |
IO.puts "Initializing FSM" | |
{:ok, :martin, nil} | |
end | |
def martin(:hello, nil) do | |
IO.puts "Hello, Paul" | |
{:next_state, :paul, nil} | |
end | |
def paul(:hello, nil) do | |
IO.puts "Hello, Martin" | |
{:next_state, :martin, nil} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment