Skip to main content

huddle_core/app/
events.rs

1use libp2p::PeerId;
2
3#[derive(Debug, Clone)]
4pub struct DiscoveredRoom {
5    pub room_id: String,
6    pub name: String,
7    pub encrypted: bool,
8    pub member_count: u32,
9    pub creator_fingerprint: String,
10    pub last_seen: i64,
11}
12
13#[derive(Debug, Clone)]
14pub enum AppEvent {
15    /// A room was discovered (announced on the global topic).
16    RoomDiscovered(DiscoveredRoom),
17    /// A previously-discovered room hasn't been re-announced — TTL expired.
18    RoomLost { room_id: String },
19    /// We successfully joined a room (subscribed to its topic).
20    RoomJoined { room_id: String },
21    /// We left a room.
22    RoomLeft { room_id: String },
23    /// A new member appeared in a room we're in.
24    MemberJoined {
25        room_id: String,
26        fingerprint: String,
27    },
28    /// A member left a room we're in.
29    MemberLeft {
30        room_id: String,
31        fingerprint: String,
32    },
33    /// A message arrived in a room.
34    MessageReceived {
35        room_id: String,
36        sender_fingerprint: String,
37        body: String,
38        sent_at: i64,
39    },
40    /// Our own message was sent successfully.
41    MessageSent {
42        room_id: String,
43        body: String,
44        message_id: i64,
45    },
46    /// Listening on a network address.
47    ListeningOn { address: String },
48    /// A peer was discovered on the LAN.
49    PeerDiscovered { peer_id: PeerId },
50    /// We've fired a dial command — useful for the UI to show "dialing...".
51    Dialing { address: String },
52    /// A user-initiated dial completed successfully.
53    DialSucceeded { address: String, peer_id: PeerId },
54    /// A user-initiated dial failed.
55    DialFailed { address: String, error: String },
56    /// Non-fatal error.
57    Error { description: String },
58}