diff options
Diffstat (limited to 'lib/app')
-rw-r--r-- | lib/app/chat.ex | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/app/chat.ex b/lib/app/chat.ex index a9cfb1e..bc9f5de 100644 --- a/lib/app/chat.ex +++ b/lib/app/chat.ex @@ -117,6 +117,7 @@ defmodule SApp.Chat do end def handle_cast({:subscribe, pid}, state) do + Process.monitor(pid) new_subs = MapSet.put(state.subs, pid) {:noreply, %{ state | subs: new_subs }} end @@ -159,6 +160,11 @@ defmodule SApp.Chat do {:noreply, %{state | store: new_store}} end + def handle_info({:DOWN, _ref, :process, pid, _reason}, state) do + new_subs = MapSet.delete(state.subs, pid) + {:noreply, %{ state | subs: new_subs }} + end + defp push_messages(state, to, start, num) do case ML.read(state.store, start, num) do {:ok, list, rest} -> |