Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. defmodule MyServer do
  2. use GenServer
  3. def init(_args) do
  4. :gproc.reg({:p, :l, :my_little_server})
  5. {:ok, []}
  6. end
  7.  
  8. def handle_info(msg, state) do
  9. IO.inspect "Got #{inspect msg} in process #{inspect self()}"
  10. {:noreply, state}
  11. end
  12. end
  13. #
  14. # iex> {:ok, pid1} = GenServer.start_link(MyServer, [], [])
  15. # iex> {:ok, pid2} = GenServer.start_link(MyServer, [], [])
  16. # iex> :gproc.send({:p, :l, :my_little_server}, :hello_world)
  17. # "Got :hello_world in process #PID<0.6726.0>"
  18. # "Got :hello_world in process #PID<0.6728.0>"
  19. # :hello_world
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement