diff options
author | Alex Auvolat <alex@adnab.me> | 2018-08-31 15:51:45 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-08-31 15:51:45 +0200 |
commit | 9d161648cc0b30dd9e0ead12f3bd5a379b26c815 (patch) | |
tree | 1f1dcbdf851981f5f36c91958814d3f99d2f99dd /lib/app | |
parent | 0faa792c979788efb8cf8b80a3534f770d8b1a65 (diff) | |
download | shard-9d161648cc0b30dd9e0ead12f3bd5a379b26c815.tar.gz shard-9d161648cc0b30dd9e0ead12f3bd5a379b26c815.zip |
Remove web interface, deregistration for chat subs on death
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} -> |