feat(protocol): away status, excluded phrases, queue-place requests
Three features the client half-had. SetStatus (28) was only ever sent as "online" at login, so there was no way to go away; excluded search phrases (160) were parsed and logged into nowhere, so every client kept spending searches on queries the server was never going to answer; and a queued download could answer a peer asking about its place but could never ask about its own. Each is now driven end to end: the away status seen by another user, a refused query on a stub server that announces phrases (soulfind keeps its filters in a database the suite cannot seed), and a peer's answer landing on the download as its queue position.
This commit is contained in:
@@ -21,6 +21,39 @@ impl Client {
|
||||
self.send_server_message(MessageFactory::build_server_ping())
|
||||
}
|
||||
|
||||
/// Set our online status (server code 28): away, or back to online.
|
||||
///
|
||||
/// Other clients see it in their `GetUserStatus` and watch replies, and
|
||||
/// the server uses it when it decides who to hand a search to.
|
||||
///
|
||||
/// # Errors
|
||||
/// [`crate::SoulseekRs::NotConnected`] when there is no server connection.
|
||||
pub fn set_away(&self, away: bool) -> Result<()> {
|
||||
let status = u32::from(!away) + 1; // away = 1, online = 2
|
||||
self.send_server_message(MessageFactory::build_set_status_message(
|
||||
status,
|
||||
))
|
||||
}
|
||||
|
||||
/// Ask `username` where the file we queued with them sits (peer code 51).
|
||||
///
|
||||
/// The answer arrives asynchronously and lands on the download, readable
|
||||
/// through [`Client::downloads`] as its queue position. A peer we have no
|
||||
/// connection to is resolved and the request delivered once it is up, the
|
||||
/// same way a browse request is.
|
||||
///
|
||||
/// # Errors
|
||||
/// [`crate::SoulseekRs::NotConnected`] when there is no server connection,
|
||||
/// or [`crate::SoulseekRs::LockPoisoned`] if the client state is poisoned.
|
||||
pub fn request_place_in_queue(
|
||||
&self,
|
||||
username: &str,
|
||||
filename: &str,
|
||||
) -> Result<()> {
|
||||
let request = MessageFactory::build_place_in_queue_request(filename);
|
||||
self.send_to_peer_or_queue(username, request)
|
||||
}
|
||||
|
||||
/// Set our ticker in `room` — the one-line message other members see.
|
||||
/// Passing an empty `ticker` clears ours.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user