Skip to main content

webrtc_direct_client/
lib.rs

1//! WebRTC Direct client for the browser (WASM).
2//!
3//! Connects to a [`webrtc-direct-server`] using the server's socket address
4//! and DTLS fingerprint, no signaling server required.
5//!
6//! # Usage
7//!
8//! ```rust,ignore
9//! use webrtc_direct_client::{WebRtcClient, FramedClient, Fingerprint};
10//! use std::net::SocketAddr;
11//!
12//! let addr: SocketAddr = ([127, 0, 0, 1], 3478).into();
13//! let fp = Fingerprint::from_hex(hex_string);
14//!
15//! let raw = WebRtcClient::connect(addr, fp).await.unwrap();
16//! let client = FramedClient::new(raw);
17//!
18//! client.send(b"hello").unwrap();
19//! let response = client.recv().await.unwrap();
20//! ```
21//!
22//! [`WebRtcClient`] gives raw DataChannel access. [`FramedClient`] wraps it
23//! with length-prefixed LZ4-compressed framing, matching the server's
24//! [`FramedReader`]/[`FramedWriter`].
25
26pub mod client;
27pub mod error;
28pub mod framed;
29pub mod sdp;
30pub use client::WebRtcClient;
31pub use error::WebRtcError;
32pub use framed::FramedClient;
33pub use webrtc_direct_protocol::{Fingerprint, Ufrag};