Skip to content

Instantly share code, notes, and snippets.

@stelcheck
Created October 31, 2016 02:18
Show Gist options
  • Save stelcheck/d2540767344554a7536c089452c4052e to your computer and use it in GitHub Desktop.
Save stelcheck/d2540767344554a7536c089452c4052e to your computer and use it in GitHub Desktop.
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