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.
Summary↑
| call(conn, opts) | Callback implementation for |
| default_config() | Provides the deault transport configuration to sockets |
| init(opts) | Callback implementation for |
| upgrade(conn, ) | |
| ws_close(state) | |
| ws_handle(opcode, payload, state) | Receives JSON encoded |
| ws_info(broadcast, state) | Detects disconnect broadcasts and shuts down |
| ws_init(conn) | Handles initalization of the websocket |
| ws_terminate(reason, state) |
Functions
Callback implementation for c:Plug.call/2.
Provides the deault transport configuration to sockets.
:serializer- ThePhoenix.Socket.Messageserializer:log- The log level, for example:info. Disabled by default:timeout- The connection timeout in milliseconds, defaults to:infinity
Callback implementation for c:Plug.init/1.
Receives JSON encoded %Phoenix.Socket.Message{} from client and dispatches
to Transport layer.
Detects disconnect broadcasts and shuts down
Handles initalization of the websocket.