Expand description
WebSocket (RFC 6455) server actions, events and metadata.
Every action declared here is executed by WebSocketProtocol::execute_action, and every
field an action documents is actually read. Two shapes of the protocol object exist:
- the registry-wide instance built by
WebSocketProtocol::new, used for documentation, spawning, and the async actions (which address a connection by id and are how the model speaks to a client nobody asked it to speak to); - a per-connection instance built by
WebSocketProtocol::for_connection, which owns the outbound channel for one socket and therefore can execute the sync actions.
No storage: [WS_CONNECTIONS] is a directory of live sockets so the model can name a
recipient. Nothing survives a disconnect, and no message is ever retained.
Structs§
- WebSocket
Protocol - WebSocket protocol action handler.
Enums§
- WsOut
- One thing the model asked us to put on the wire for a connection.
Constants§
- OPENED_
ANSWER_ WITH - The
answer_withfield ofwebsocket_connection_opened. - TEXT_
MESSAGE_ ANSWER_ WITH - The
answer_withfield ofwebsocket_text_message.
Statics§
- ACCEPT_
WEBSOCKET_ ACTION - CLOSE_
WEBSOCKET_ ACTION - REJECT_
WEBSOCKET_ ACTION - SEND_
WEBSOCKET_ BINARY_ ACTION - SEND_
WEBSOCKET_ PING_ ACTION - SEND_
WEBSOCKET_ TEXT_ ACTION - WAIT_
FOR_ WEBSOCKET_ DATA_ ACTION - WEBSOCKET_
BINARY_ MESSAGE_ EVENT - Emitted for every reassembled binary message. See
WebSocketServer::handle_inbound. - WEBSOCKET_
CLOSE_ EVENT - Emitted when the client starts the closing handshake. See
WebSocketServer::run_connection. - WEBSOCKET_
CONNECTION_ OPENED_ EVENT - Emitted immediately after the 101 response is written. This is the server’s chance to
speak first. See
WebSocketServer::run_connection. - WEBSOCKET_
HANDSHAKE_ EVENT - Emitted for every well-formed upgrade request, before any 101 is written.
See
WebSocketServer::handle_connection. - WEBSOCKET_
PING_ EVENT - Emitted for every ping control frame. The pong is sent automatically by the framing layer; this event exists so the model can react to a heartbeat (e.g. push fresh data).
- WEBSOCKET_
TEXT_ MESSAGE_ EVENT - Emitted for every reassembled text message. See
WebSocketServer::handle_inbound.
Functions§
- accept_
websocket_ action - close_
websocket_ action - close_
websocket_ connection_ action - decode_
outbound_ payload - Turn an action’s
data+encodingpair into the exact bytes to put on the wire. - encode_
inbound_ payload - Turn received binary-frame bytes into the
(data, encoding)pair the model sees. - get_
websocket_ event_ types - All WebSocket server event types. Each is emitted by
src/server/websocket/mod.rs. - handshake_
answer_ with - The
answer_withfield ofwebsocket_handshake: what this upgrade takes. - list_
connections - Describe the connections currently open, optionally restricted to one server.
- list_
websocket_ connections_ action - push_
websocket_ binary_ action - push_
websocket_ text_ action - register_
connection - Record a connection’s writer so actions can address it by id.
- reject_
websocket_ action - send_
websocket_ binary_ action - send_
websocket_ ping_ action - send_
websocket_ text_ action - set_
connection_ subprotocol - Record the negotiated subprotocol once the handshake has completed.
- unregister_
connection - Drop a connection from the directory when its socket ends.
- wait_
for_ websocket_ data_ action