Module websocket

Module websocket 

Source
Expand description

This module implements WebSocket support for Dioxus Fullstack applications.

WebSockets provide a full-duplex communication channel over a single, long-lived connection.

This makes them ideal for real-time applications where the server and the client need to communicate frequently and with low latency. Unlike Server-Sent Events (SSE), WebSockets allow the direct transport of binary data, enabling things like video and audio streaming as well as more efficient zero-copy serialization formats.

This module implements a variety of types:

  • Websocket<In, Out, E>: Represents a WebSocket connection that can send messages of type In and receive messages of type Out, using the encoding E.
  • UseWebsocket<In, Out, E>: A hook that provides a reactive interface to a WebSocket connection.
  • WebSocketOptions: Configuration options for establishing a WebSocket connection.
  • TypedWebsocket<In, Out, E>: A typed wrapper around an Axum WebSocket connection for server-side use.
  • WebsocketState: An enum representing the state of the WebSocket connection.
  • plus a variety of error types and traits for encoding/decoding messages.

Dioxus Fullstack websockets are typed in both directions, letting the happy path (.send() and .recv()) automatically serialize and deserialize messages for you.

Structs§

UseWebsocket
The return type of the use_websocket hook.
WebSocketOptions
Websocket
A WebSocket connection that can send and receive messages of type In and Out.

Enums§

CloseCode
Status code used to indicate why an endpoint is closing the WebSocket connection.1
Message
A WebSocket message, which can be a text string or binary data.
WebsocketError
WebsocketState

Functions§

use_websocket
A hook that provides a reactive interface to a WebSocket connection.