Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule MyServer do
- use GenServer
- def init(_args) do
- :gproc.reg({:p, :l, :my_little_server})
- {:ok, []}
- end
- def handle_info(msg, state) do
- IO.inspect "Got #{inspect msg} in process #{inspect self()}"
- {:noreply, state}
- end
- end
- #
- # iex> {:ok, pid1} = GenServer.start_link(MyServer, [], [])
- # iex> {:ok, pid2} = GenServer.start_link(MyServer, [], [])
- # iex> :gproc.send({:p, :l, :my_little_server}, :hello_world)
- # "Got :hello_world in process #PID<0.6726.0>"
- # "Got :hello_world in process #PID<0.6728.0>"
- # :hello_world
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement