huddle_core/network/events.rs
1use libp2p::{Multiaddr, PeerId};
2
3use crate::network::protocol::RoomAnnouncement;
4
5#[derive(Debug, Clone)]
6pub enum NetworkEvent {
7 /// A peer was discovered on the LAN (mDNS).
8 PeerDiscovered { peer_id: PeerId },
9 /// A peer's mDNS record expired.
10 PeerExpired { peer_id: PeerId },
11 /// A room was announced on the global rooms topic.
12 RoomAnnouncementReceived(RoomAnnouncement),
13 /// A raw message arrived on a per-room topic. Payload is the
14 /// JSON-encoded `RoomMessage` — decoded by the app layer.
15 RoomMessageReceived {
16 room_id: String,
17 payload: Vec<u8>,
18 from_peer: PeerId,
19 },
20 ListeningOn { address: Multiaddr },
21 /// A user-initiated dial to `address` succeeded — the remote peer
22 /// is `peer_id` and the swarm now has an open connection.
23 DialSucceeded { peer_id: PeerId, address: Multiaddr },
24 /// A user-initiated dial failed before establishing a connection.
25 DialFailed { address: Multiaddr, error: String },
26}