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 Router’s transport configuration:

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

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

Source

Summary

action(conn, options)
call(conn, action)

Callback implementation of Plug.call/2

init(action)

Callback implementation of Plug.init/1

upgrade_conn(conn, )
ws_handle(text, state)

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

ws_hibernate(state)
ws_info(message, state)

Handles Elixir messages sent to the socket process

ws_init(conn)

Handles initalization of the websocket

ws_terminate(reason, arg2)

Called on WS close. Dispatches the leave event back through Transport layer

Functions

action(conn, options)
Source
call(conn, action)

Callback implementation of Plug.call/2.

Source
init(action)

Callback implementation of Plug.init/1.

Source
upgrade_conn(conn, )
Source
ws_handle(text, state)

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

Source
ws_hibernate(state)
Source
ws_info(message, state)

Handles Elixir messages sent to the socket process

Dispatches "info" event back through Tranport layer to all socket’s channels

Source
ws_init(conn)

Handles initalization of the websocket

Source
ws_terminate(reason, arg2)

Called on WS close. Dispatches the leave event back through Transport layer

Source