Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (23 sloc) 600 Bytes
defmodule PhatWeb.Presence do
use Phoenix.Presence,
otp_app: :phat,
pubsub_server: Phat.PubSub
alias PhatWeb.Presence
def track_presence(pid, topic, key, payload) do
Presence.track(pid, topic, key, payload)
end
def update_presence(pid, topic, key, payload) do
metas =
Presence.get_by_key(topic, key)[:metas]
|> List.first()
|> Map.merge(payload)
Presence.update(pid, topic, key, metas)
end
def list_presences(topic) do
Presence.list(topic)
|> Enum.map(fn {_user_id, data} ->
data[:metas]
|> List.first()
end)
end
end
You can’t perform that action at this time.