phoenix_gen_socket_client v1.0.0 Phoenix.Channels.GenSocketClient.TestSocket

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.

Summary

Functions

Awaits a message from the socket

Connect to the server

Joins a topic on the connected socket

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

Waits until the socket is connected or disconnected

Functions

await_message(socket, timeout \\ 5000)

Awaits a message from the socket.

connect(socket)

Specs

connect(GenServer.server) :: :ok

Connect to the server.

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

Joins a topic on the connected socket.

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

Leaves the topic.

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

Pushes a message to the topic.

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

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

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

Starts the driver process.

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

Specs

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

Waits until the socket is connected or disconnected