mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-11-24 08:51:00 +00:00
use genserver pid or name in client API
This commit is contained in:
parent
0bde8f40d6
commit
84d4eead7a
1 changed files with 10 additions and 5 deletions
|
@ -11,15 +11,20 @@ defmodule Phoenix.Presence.Client do
|
|||
* `:client` - The required callback module
|
||||
"""
|
||||
def start_link(opts) do
|
||||
GenServer.start_link(__MODULE__, opts, name: PresenceClient)
|
||||
case Keyword.fetch(opts, :name) do
|
||||
{:ok, name} ->
|
||||
GenServer.start_link(__MODULE__, opts, name: name)
|
||||
|
||||
:error -> GenServer.start_link(__MODULE__, opts)
|
||||
end
|
||||
end
|
||||
|
||||
def track(topic, key, meta) do
|
||||
GenServer.call(PresenceClient, {:track, self(), topic, to_string(key), meta})
|
||||
def track(pid \\ PresenceClient, topic, key, meta) do
|
||||
GenServer.call(pid, {:track, self(), topic, to_string(key), meta})
|
||||
end
|
||||
|
||||
def untrack(topic, key) do
|
||||
GenServer.call(PresenceClient, {:untrack, self(), topic, to_string(key)})
|
||||
def untrack(pid \\ PresenceClient, topic, key) do
|
||||
GenServer.call(pid, {:untrack, self(), topic, to_string(key)})
|
||||
end
|
||||
|
||||
def init(opts) do
|
||||
|
|
Loading…
Reference in a new issue