Phoenix.SocketClient (phoenix_socket_client v0.7.0)

The main API for the Phoenix Socket Client.

Summary

Functions

Joins a channel through the socket.

Returns a child specification for the socket client supervisor.

Connects the socket.

Checks if the socket is connected.

Disconnects the socket.

Gets the entire socket state.

Gets a value from the socket state.

Pushes a message through the socket.

Puts a value into the socket state.

Removes a channel from the list of joined channels. For internal use.

Starts the socket client supervisor.

Updates the status of a channel. For internal use.

Functions

channel_join(sup_pid, topic, params \\ %{})

@spec channel_join(pid(), binary(), map()) ::
  {:ok, pid()}
  | {:error, :channel_manager_not_found | {:already_started, pid()}}

Joins a channel through the socket.

channel_leave(sup_pid, channel_pid)

@spec channel_leave(pid(), pid()) :: :ok

Leaves a channel.

child_spec(options)

@spec child_spec(keyword()) :: Supervisor.child_spec()

Returns a child specification for the socket client supervisor.

Delegates to Phoenix.SocketClient.Supervisor.child_spec/1.

connect(sup_pid)

@spec connect(pid() | atom()) :: :ok | {:error, :no_socket_found}

Connects the socket.

connected?(sup_pid)

@spec connected?(pid() | atom()) :: boolean()

Checks if the socket is connected.

disconnect(sup_pid)

@spec disconnect(pid() | atom()) :: :ok

Disconnects the socket.

get_state(name)

@spec get_state(pid() | atom()) :: map()

Gets the entire socket state.

get_state(name, key)

@spec get_state(pid() | atom(), atom()) :: any()

Gets a value from the socket state.

push(sup_pid, message)

Pushes a message through the socket.

put_state(name, key, value)

@spec put_state(pid() | atom(), atom(), any()) :: :ok

Puts a value into the socket state.

remove_channel(sup_pid, topic)

@spec remove_channel(pid(), String.t()) :: :ok

Removes a channel from the list of joined channels. For internal use.

start_link(options)

@spec start_link(keyword()) :: Supervisor.on_start()

Starts the socket client supervisor.

Delegates to Phoenix.SocketClient.Supervisor.start_link/1.

update_channel_status(sup_pid, channel_pid, topic, status, params \\ nil)

@spec update_channel_status(pid(), pid(), String.t(), atom(), map() | nil) :: :ok

Updates the status of a channel. For internal use.