Skip to main content

Module actions

Module actions 

Source
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§

WebSocketProtocol
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_with field of websocket_connection_opened.
TEXT_MESSAGE_ANSWER_WITH
The answer_with field of websocket_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 + encoding pair 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_with field of websocket_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