#[non_exhaustive]pub struct RoomsNode {
pub node: Node,
pub rooms: Rooms,
pub router: Router,
}Expand description
A node that serves both live broadcasts and rooms, with its router.
The node takes the union of LiveLayout and [RoomsLayout], so a
member publishes under its room paths and under its own live paths. The
router accepts the node’s sessions and the rooms’ gossip, so other
members can reach this one.
§Examples
use iroh_live::{EndpointConfig, RoomsNode, rooms::RoomTicket};
let live = RoomsNode::bind(EndpointConfig::from_env()?).await?;
let room = live.rooms.join(&RoomTicket::generate(), Some("ada".into())).await?;
println!("room ticket: {}", room.ticket());
// At exit.
live.shutdown().await;Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.node: NodeThe node, configured with the live and the rooms layout.
rooms: RoomsThe room service on the node’s endpoint.
router: RouterThe router that accepts the node’s sessions and the rooms’ gossip.
Implementations§
Source§impl RoomsNode
impl RoomsNode
Sourcepub async fn bind(config: EndpointConfig) -> Result<Self, EndpointError>
pub async fn bind(config: EndpointConfig) -> Result<Self, EndpointError>
Binds an endpoint with config and serves live broadcasts and rooms on it.
§Errors
Fails if the endpoint cannot be bound.
Sourcepub async fn shutdown(&self)
pub async fn shutdown(&self)
Leaves every joined room, then shuts the node and the router down.
Leaving tells the other members at once, see [Rooms::leave_all].
Only rooms that a handle still holds are left, since a room stops
with its last handle. The router’s shutdown stops the node and the
rooms, then closes the endpoint. Each step is bounded: leaving takes
seconds at most even with every other member gone, and closing the
endpoint waits for each peer to acknowledge the close, for up to a
few seconds for a peer that vanished.
Not cancellation safe. A shutdown cut short, such as by a timeout around it, can leave the endpoint dropped without being closed, so let it finish.