diff --git a/lib/chat/server.ex b/lib/chat/server.ex index 8cee829..b073192 100644 --- a/lib/chat/server.ex +++ b/lib/chat/server.ex @@ -3,7 +3,7 @@ defmodule Chat.Server do # API - def start_link do + def start_link(name) do GenServer.start_link(__MODULE__, [], name: :chat_room) end diff --git a/lib/chat/supervisor.ex b/lib/chat/supervisor.ex index 9d982ed..92afb0f 100644 --- a/lib/chat/supervisor.ex +++ b/lib/chat/supervisor.ex @@ -2,7 +2,11 @@ defmodule Chat.Supervisor do use Supervisor def start_link do - Supervisor.start_link(__MODULE__, []) + Supervisor.start_link(__MODULE__, [], name: :chat_supervisor) + end + + def start_room(name) do + Supervisor.start_child(:chat_supervisor, [name]) end def init(_) do @@ -10,6 +14,6 @@ defmodule Chat.Supervisor do worker(Chat.Server, []) ] - supervise(children, strategy: :one_for_one) + supervise(children, strategy: :simple_one_for_one) end end