phoenix_gen_socket_client v3.0.0 Phoenix.Channels.GenSocketClient.TestSocket View Source

A simple synchronous Phoenix Channels client.

This module can be used in your project for testing your own functionality. The module implements the Phoenix.Channels.GenSocketClient behaviour to provide a controllable API for channel clients. The implementation is very basic, and is useful for tests only. It's not advised to use this module in production, because there are various edge cases which can cause subtle bugs. You're instead advised to implement your own callback for the Phoenix.Channels.GenSocketClient behaviour.

Link to this section Summary

Functions

Awaits a message from the socket.

Connect to the server.

Connect to the server and override/replace the initialized url and query params.

Joins a topic on the connected socket.

Returns true if the socket is joined on the given topic.

Pushes a message to the topic and awaits the direct response from the server.

Waits until the socket is connected or disconnected

Link to this section Functions

Link to this function

await_message(socket, timeout \\ 5000)

View Source

Specs

Awaits a message from the socket.

Specs

connect(GenServer.server()) :: :ok

Connect to the server.

Link to this function

connect(socket, url, query_params)

View Source

Specs

Connect to the server and override/replace the initialized url and query params.

Link to this function

join(socket, topic, payload \\ %{}, timeout \\ 5000)

View Source

Specs

Joins a topic on the connected socket.

Specs

Returns true if the socket is joined on the given topic.

Link to this function

leave(socket, topic, payload \\ %{}, timeout \\ 5000)

View Source

Specs

Leaves the topic.

Link to this function

push(socket, topic, event, payload \\ %{}, timeout \\ 5000)

View Source

Specs

Pushes a message to the topic.

Link to this function

push_sync(socket, topic, event, payload \\ %{}, timeout \\ 5000)

View Source

Specs

Pushes a message to the topic and awaits the direct response from the server.

Link to this function

start_link(transport, url, query_params, connect \\ true, socket_opts \\ [])

View Source

Specs

Starts the driver process.

Link to this function

wait_connect_status(socket, timeout \\ :timer.seconds(5))

View Source

Specs

wait_connect_status(GenServer.server(), GenServer.timeout()) ::
  :connected | {:disconnected, any()} | {:error, :timeout}

Waits until the socket is connected or disconnected