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, but the serializer is configurable via the Endpoint’s transport configuration:

config :my_app, MyApp.Endpoint, transports: [
  websocket_serializer: MySerializer
]

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

Websockets, by default, do not timeout if the connection is lost. To set a maximum timeout duration in milliseconds, add this to your Endpoint’s transport configuration:

config :my_app, MyApp.Endpoint, transports: [
  websocket_timeout: 60000
]
Source

Summary

call(conn, opts)

Callback implementation of Plug.call/2

init(opts)

Callback implementation of Plug.init/1

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

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

ws_info(arg1, state)
ws_init(conn)

Handles initalization of the websocket

ws_terminate(reason, state)

Functions

call(conn, opts)

Callback implementation of Plug.call/2.

Source
init(opts)

Callback implementation of Plug.init/1.

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

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

Source
ws_info(arg1, state)
Source
ws_init(conn)

Handles initalization of the websocket.

Source
ws_terminate(reason, state)
Source