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:
@@ -301,6 +301,15 @@ impl MessageFactory {
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// Ask a peer where the file we queued with them sits (peer code 51).
|
||||
#[must_use]
|
||||
pub fn build_place_in_queue_request(filename: &str) -> Message {
|
||||
Message::new()
|
||||
.write_int32(51)
|
||||
.write_string(filename)
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// A keepalive ping (server code 32, no body). The server sends no reply;
|
||||
/// its only job is to keep a quiet connection from being reaped by a NAT
|
||||
/// or the server's own idle timeout, the way other clients ping.
|
||||
@@ -687,6 +696,15 @@ fn an_upload_speed_report_carries_the_rate() {
|
||||
assert_eq!(decoded.read_int32(), 900);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_place_in_queue_request_names_the_file() {
|
||||
let message = MessageFactory::build_place_in_queue_request("a\\b.mp3");
|
||||
let mut decoded = Message::new_with_data(message.get_buffer());
|
||||
assert_eq!(decoded.get_message_code(), 51);
|
||||
decoded.set_pointer(8);
|
||||
assert_eq!(decoded.read_string(), "a\\b.mp3");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_ping_is_just_its_code() {
|
||||
let message = MessageFactory::build_server_ping();
|
||||
|
||||
Reference in New Issue
Block a user