phoenix_client v0.11.1 PhoenixClient.Channel

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Join a channel topic through a socket with optional params

Leave the channel topic and stop the channel

Push a message to the server and wait for a response or timeout

Push a message to the server and do not wait for a response

Link to this section Functions

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

join(socket_pid_or_name, topic, params \\ %{}, timeout \\ 5000)

Specs

join(pid() | atom(), binary(), map(), non_neg_integer()) ::
  {:ok, map(), pid()}
  | {:error, :socket_not_connected}
  | {:error, :timeout}
  | {:error, any()}

Join a channel topic through a socket with optional params

A socket can only join a topic once. If the socket you pass already has a channel connection for the supplied topic, you will receive an error {:error, {:already_joined, pid}} with the channel pid of the process joined to that topic through that socket. If you require to join the same topic with multiple processes, you will need to start a new socket process for each channel.

Calling join will link the caller to the channel process.

Specs

leave(pid()) :: :ok

Leave the channel topic and stop the channel

Link to this function

push(pid, event, payload, timeout \\ 5000)

Specs

push(pid(), binary(), map(), non_neg_integer()) :: term()

Push a message to the server and wait for a response or timeout

The server must be configured to return {:reply, _, socket} otherwise, the call will timeout.

Link to this function

push_async(pid, event, payload)

Specs

push_async(pid(), binary(), map()) :: :ok

Push a message to the server and do not wait for a response