Files
soulseek-rs-modded/soulseek-rs-lib/src/message/peer/transfer_response.rs
T
Michel de Graaf f1aa94fecc fix(lib): route on the full four-byte message code
Dispatch read one byte of the code, so a code with a non-zero high byte
was handled as its low byte. Message::get_message_code now reads the
whole little-endian uint32 and handlers register by u32. PeerInit and
PierceFirewall, the only frames with a one-byte code, get their own
accessor for the listener's first frame.
2026-09-07 15:03:49 +02:00

26 lines
628 B
Rust

use crate::{
message::{Message, MessageHandler},
peer::PeerMessage,
};
use std::sync::mpsc::Sender;
pub struct TransferResponse;
impl MessageHandler<PeerMessage> for TransferResponse {
fn get_code(&self) -> u32 {
41
}
fn handle(&self, message: &mut Message, sender: Sender<PeerMessage>) {
let token = message.read_int32();
let allowed = message.read_int8();
let reason = (allowed == 0).then(|| message.read_string());
let _ = sender.send(PeerMessage::TransferResponse {
token,
allowed: allowed == 1,
reason,
});
}
}