summaryrefslogtreecommitdiff
path: root/lib/chessh/schema/player_session.ex
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chessh/schema/player_session.ex')
-rw-r--r--lib/chessh/schema/player_session.ex8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/chessh/schema/player_session.ex b/lib/chessh/schema/player_session.ex
index b16519f..f12387a 100644
--- a/lib/chessh/schema/player_session.ex
+++ b/lib/chessh/schema/player_session.ex
@@ -108,4 +108,12 @@ defmodule Chessh.PlayerSession do
3_000 -> false
end
end
+
+ def close_all_player_sessions(player) do
+ player_sessions = Repo.all(from(p in PlayerSession, where: p.player_id == ^player.id))
+
+ Enum.map(player_sessions, fn session ->
+ :syn.publish(:player_sessions, {:session, session.id}, :session_closed)
+ end)
+ end
end