feat(protocol): interests, tickers, global room and cant-connect

Adds the server messages the client had no way to speak: user and room
search (42/120), room tickers (113-116), the global room feed (150-152),
interests and the recommendation queries built on them (51/52/54/56/57/
110/111/112/117/118), a keepalive ping (32), gifted privileges (123), a
password change (142) and multi-user private messages (149).

CantConnectToPeer (1001) closes a real gap in both directions: a dial the
server asked us to make now answers the waiting peer instead of falling
back to brokering the same unreachable link the other way, and an incoming
one ends the wait on downloads queued for that peer rather than letting
them sit until a timeout.
This commit is contained in:
Michel de Graaf
2026-09-09 16:19:40 +00:00
parent 374a81bec1
commit 886f1b7092
18 changed files with 1886 additions and 18 deletions
+52
View File
@@ -393,6 +393,58 @@ pub enum RoomEvent {
UserJoined { room: String, username: String },
/// `username` left `room`.
UserLeft { room: String, username: String },
/// The full ticker board of `room`, sent when we join it (code 113).
Tickers {
room: String,
tickers: Vec<RoomTicker>,
},
/// `username` set their ticker in `room` (code 114). It replaces any
/// previous ticker of theirs.
TickerAdded {
room: String,
username: String,
ticker: String,
},
/// `username` cleared their ticker in `room` (code 115).
TickerRemoved { room: String, username: String },
/// A message said in *any* public room, delivered because we joined the
/// global room feed (code 152). `room` names where it was said.
GlobalMessage {
room: String,
username: String,
message: String,
},
}
/// One user's ticker (the scrolling one-line message) in a room.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RoomTicker {
pub username: String,
pub ticker: String,
}
/// One recommended item and how strongly the server recommends it. The rating
/// is signed: a negative rating means the item is recommended *against*.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Recommendation {
pub item: String,
pub rating: i32,
}
/// A user the server considers similar to us, with the weight (the number of
/// interests shared) it scored them by.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SimilarUser {
pub username: String,
pub weight: u32,
}
/// What a user likes and hates (`UserInterests`, code 57).
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct UserInterests {
pub username: String,
pub likes: Vec<String>,
pub hates: Vec<String>,
}
impl Transfer {