defmodule BeetRoundServer.BiddingRounds.BiddingRoundServer do use GenServer def inc(pid), do: GenServer.cast(pid, :inc) def dec(pid), do: GenServer.cast(pid, :dec) def val(pid) do GenServer.call(pid, :val) end def stop(pid) do GenServer.stop(pid) end def start(initial_val) do GenServer.start(__MODULE__, initial_val, name: CurrentRoundServer) end def init(initial_val) do {:ok, initial_val} end def terminate(_reason, val) do IO.puts("Stopping bidding round:") IO.puts(val) :ok end def handle_cast(:inc, val) do {:noreply, val + 1} end def handle_cast(:dec, val) do {:noreply, val - 1} end def handle_call(:val, _from, val) do {:reply, val, val} end end