Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/phoenix_client/socket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ defmodule PhoenixClient.Socket do
GenServer.call(pid, {:push, message})
end

def listen(pid, topic, send_to) do
GenServer.call(pid, {:channel_listen, topic, send_to})
end

@doc false
def channel_join(pid, channel, topic, params) do
GenServer.call(pid, {:channel_join, channel, topic, params})
Expand Down Expand Up @@ -135,6 +139,10 @@ defmodule PhoenixClient.Socket do
end
end

def handle_call({:channel_listen, topic, to}, _from, %{channels: channels} = state) do
{:reply, :ok, %{state | channels: Map.put(channels, topic, {to, :ignore})}}
end

@impl true
def handle_call({:channel_leave, _channel, topic}, _from, %{channels: channels} = state) do
case Map.get(channels, topic) do
Expand Down