A registry/supervisor setup copied from Brian Storti's blog.
If available in Hex, the package can be installed
by adding chat
to your list of dependencies in mix.exs
:
def deps do
[
{:chat, "~> 0.1.0"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/chat.
Chat.Supervisor.start_link
Chat.Supervisor.start_room("room1")
Chat.Supervisor.start_room("room2")
Chat.Server.add_message("room1", "first message")
Chat.Server.add_message("room2", "second message")
Chat.Server.get_messages("room1")
Chat.Server.get_messages("room2")
Registry.whereis_name({:room_registry, "room1"}) |> Process.exit(:kill)
Chat.Server.add_message("room1", "message2")
Chat.Server.get_messages("room1")