phoenix_gen_socket_client v3.2.1 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.
Leaves the topic.
Pushes a message to the topic.
Pushes a message to the topic and awaits the direct response from the server.
Starts the driver process.
Waits until the socket is connected or disconnected
Link to this section Functions
Specs
await_message(GenServer.server(), GenServer.timeout()) :: {:ok, Phoenix.Channels.GenSocketClient.topic(), Phoenix.Channels.GenSocketClient.event(), Phoenix.Channels.GenSocketClient.payload()} | {:error, :timeout}
Awaits a message from the socket.
Specs
connect(GenServer.server()) :: :ok
Connect to the server.
Specs
connect( GenServer.server(), String.t(), Phoenix.Channels.GenSocketClient.query_params() ) :: :ok
Connect to the server and override/replace the initialized url and query params.
Specs
join( GenServer.server(), Phoenix.Channels.GenSocketClient.topic(), Phoenix.Channels.GenSocketClient.payload(), GenServer.timeout() ) :: {:ok, {Phoenix.Channels.GenSocketClient.topic(), Phoenix.Channels.GenSocketClient.payload()}} | {:error, any()}
Joins a topic on the connected socket.
Specs
joined?(GenServer.server(), Phoenix.Channels.GenSocketClient.topic()) :: boolean()
Returns true if the socket is joined on the given topic.
Specs
leave( GenServer.server(), Phoenix.Channels.GenSocketClient.topic(), Phoenix.Channels.GenSocketClient.payload(), GenServer.timeout() ) :: {:ok, Phoenix.Channels.GenSocketClient.payload()} | {:error, any()}
Leaves the topic.
Specs
push( GenServer.server(), Phoenix.Channels.GenSocketClient.topic(), Phoenix.Channels.GenSocketClient.event(), Phoenix.Channels.GenSocketClient.payload(), GenServer.timeout() ) :: {:ok, Phoenix.Channels.GenSocketClient.ref()} | {:error, any()}
Pushes a message to the topic.
Specs
push_sync( GenServer.server(), Phoenix.Channels.GenSocketClient.topic(), Phoenix.Channels.GenSocketClient.event(), Phoenix.Channels.GenSocketClient.payload(), GenServer.timeout() ) :: {:ok, Phoenix.Channels.GenSocketClient.payload()} | {:error, any()}
Pushes a message to the topic and awaits the direct response from the server.
start_link(transport, url, query_params, connect \\ true, socket_opts \\ [])
View SourceSpecs
start_link( module(), String.t(), Phoenix.Channels.GenSocketClient.query_params(), boolean(), Phoenix.Channels.GenSocketClient.socket_opts() ) :: GenServer.on_start()
Starts the driver process.
Specs
wait_connect_status(GenServer.server(), GenServer.timeout()) :: :connected | {:disconnected, any()} | {:error, :timeout}
Waits until the socket is connected or disconnected