Phoenix.Transports.LongPoll
Handles LongPoll clients for the Channel Transport layer.
Configuration
The long poller is configurable in your Socket’s transport configuration:
transport :longpoll, Phoenix.Transports.LongPoll,
window_ms: 10_000,
pubsub_timeout_ms: 1000,
crypto: [iterations: 1000,
length: 32,
digest: :sha256,
cache: Plug.Keys],
:window_ms- how long the client can wait for new messages in it’s poll request.:pubsub_timeout_ms- how long a request can wait for the pubsub layer to respond.:crypto- configuration for the key generated to sign the private topic used for the long poller session (seePlug.Crypto.KeyGenerator).
Summary↑
| ack(conn, priv_topic, msgs) | Ack’s a list of message refs back to the |
| call(conn, opts) | Callback implementation for |
| default_config() | Provides the deault transport configuration to sockets |
| init(opts) | Callback implementation for |
| options(conn, params) | Responds to pre-flight CORS requests with Allow-Origin-* headers |
| poll(conn, params) | Listens for |
| publish(conn, message) | Publishes a |
| resume_session(conn) | Finds the |
| start_session(conn, socket) | Starts the |
| transport_dispatch(conn, priv_topic, msg) | Dispatches deserialized |
| verify_longpoll_topic(conn) | Retrieves the serialized |
Functions
Ack’s a list of message refs back to the Phoenix.LongPoll.Server.
To be called after buffered messages have been relayed to the client.
Callback implementation for c:Plug.call/2.
Provides the deault transport configuration to sockets.
:serializer- ThePhoenix.Socket.Messageserializer:pubsub_timeout_ms- The timeout to wait for the LongPoll.Server ack:log- The log level, for example:info. Disabled by default:timeout- The connection timeout in milliseconds, defaults to:infinity:crypto- The list of encryption options for thePlug.Session
Callback implementation for c:Plug.init/1.
Responds to pre-flight CORS requests with Allow-Origin-* headers.
Listens for %Phoenix.Socket.Message{}‘s from Phoenix.LongPoll.Server.
As soon as messages are received, they are encoded as JSON and sent down
to the longpolling client, which immediately repolls. If a timeout occurs,
a :no_content response is returned, and the client should immediately repoll.
Publishes a %Phoenix.Socket.Message{} to a channel.
If the message was authorized by the Channel, a 200 OK response is returned, otherwise a 401 Unauthorized response is returned.
Finds the Phoenix.LongPoll.Server server from the session.
Starts the Phoenix.LongPoll.Server and stores the serialized pid in the session.
Dispatches deserialized %Phoenix.Socket.Message{} from client to
Phoenix.LongPoll.Server
Retrieves the serialized Phoenix.LongPoll.Server pid from the encrypted token.