Skip to content

Commit

Permalink
Add GenServer call for getting state
Browse files Browse the repository at this point in the history
  • Loading branch information
alecho committed Sep 25, 2019
1 parent d7d3c25 commit 1ba9573
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/chex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ defmodule Chex do
GenServer.call(pid, :engine_move)
end

def state(pid) when is_pid(pid) do
GenServer.call(pid, :state)
end

@doc """
End a game process.
Expand Down
4 changes: 2 additions & 2 deletions lib/chex/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ defmodule Chex.Server do
end

@impl true
def handle_call(:ping, _from, state) do
{:reply, :pong, state}
def handle_call(:state, _from, state) do
{:reply, state, state}
end

@impl true
Expand Down

0 comments on commit 1ba9573

Please sign in to comment.