Phoenix.Transports.WebSocket

Handles WebSocket clients for the Channel Transport layer.

Configuration

By default, JSON encoding is used to broker messages to and from clients and Websockets, by default, do not timeout if the connection is lost. The maximum timeout duration and serializer can be configured in your Socket’s transport configuration:

transport :websocket, Phoenix.Transports.WebSocket,
  serializer: MySerializer
  timeout: 60000

The serializer module needs only to implement the encode!/1 and decode!/2 functions defined by the Phoenix.Transports.Serializer behaviour.

Source

Summary

call(conn, opts)

Callback implementation for c:Plug.call/2

default_config()

Provides the deault transport configuration to sockets

init(opts)

Callback implementation for c:Plug.init/1

upgrade(conn, )
ws_close(state)
ws_handle(opcode, payload, state)

Receives JSON encoded %Phoenix.Socket.Message{} from client and dispatches to Transport layer

ws_info(broadcast, state)

Detects disconnect broadcasts and shuts down

ws_init(conn)

Handles initalization of the websocket

ws_terminate(reason, state)

Functions

call(conn, opts)

Callback implementation for c:Plug.call/2.

Source
default_config()

Provides the deault transport configuration to sockets.

  • :serializer - The Phoenix.Socket.Message serializer
  • :log - The log level, for example :info. Disabled by default
  • :timeout - The connection timeout in milliseconds, defaults to :infinity
Source
init(opts)

Callback implementation for c:Plug.init/1.

Source
upgrade(conn, )
Source
ws_close(state)
Source
ws_handle(opcode, payload, state)

Receives JSON encoded %Phoenix.Socket.Message{} from client and dispatches to Transport layer.

Source
ws_info(broadcast, state)

Detects disconnect broadcasts and shuts down

Source
ws_init(conn)

Handles initalization of the websocket.

Source
ws_terminate(reason, state)
Source