mirror of
https://github.com/correl/planning-poker.git
synced 2024-11-22 03:00:12 +00:00
Clear player data on socket closure
This commit is contained in:
parent
acf1f812c8
commit
2b804d30f7
2 changed files with 11 additions and 0 deletions
|
@ -35,6 +35,11 @@ defmodule Planningpoker.Db do
|
||||||
:ets.select(:players, match)
|
:ets.select(:players, match)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def remove_player(player, room) do
|
||||||
|
:ets.delete(:players, {player, room})
|
||||||
|
:ets.delete(:votes, {player, room})
|
||||||
|
end
|
||||||
|
|
||||||
def clear_votes(room) do
|
def clear_votes(room) do
|
||||||
:ets.match_delete(:votes, {{:_, room}, :_})
|
:ets.match_delete(:votes, {{:_, room}, :_})
|
||||||
votes = :ets.match(:votes, {{:_, room}, :"$1"})
|
votes = :ets.match(:votes, {{:_, room}, :"$1"})
|
||||||
|
|
|
@ -49,4 +49,10 @@ defmodule PlanningpokerWeb.RoomChannel do
|
||||||
def handle_in(_event, _data, socket) do
|
def handle_in(_event, _data, socket) do
|
||||||
{:noreply, socket}
|
{:noreply, socket}
|
||||||
end
|
end
|
||||||
|
def terminate(reason, socket) do
|
||||||
|
Db.remove_player(
|
||||||
|
socket.assigns.player_id,
|
||||||
|
socket.assigns.room_id
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue