Phoenix.Transports.WebSocket
Phoenix.Transports.WebSocket
Socket transport for websocket clients.
Configuration
The websocket is configurable in your socket:
transport :websocket, Phoenix.Transports.WebSocket,
timeout: :infinity,
serializer: Phoenix.Transports.WebSocketSerializer,
transport_log: false
-
:timeout
- the timeout for keeping websocket connections open after it last received data, defaults to 60_000ms -
:transport_log
- if the transport layer itself should log and, if so, the level -
:serializer
- the serializer for websocket messages -
:check_origin
- if we should check the origin of requests when the origin header is present. It defaults to true and, in such cases, it will check against the host value inYourApp.Endpoint.config(:url)[:host]
. It may be set tofalse
(not recommended) or to a list of explicitly allowed origins -
:code_reloader
- optionally override the default:code_reloader
value from the socket’s endpoint
Serializer
By default, JSON encoding is used to broker messages to and from clients. A custom serializer may be given as module which implements the encode!/1
and decode!/2
functions defined by the Phoenix.Transports.Serializer
behaviour.
The encode!/1
function must return a tuple in the format {:socket_push, :text | :binary, String.t | binary}
.
Summary
Functions
Functions
default_config()
© 2014 Chris McCord
Licensed under the MIT License.
https://hexdocs.pm/phoenix/Phoenix.Transports.WebSocket.html