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.
22 lines
667 B
Rust
22 lines
667 B
Rust
use crate::debug;
|
|
use std::sync::mpsc::Sender;
|
|
|
|
use crate::{
|
|
actor::server_actor::ServerMessage,
|
|
message::{Message, MessageHandler},
|
|
};
|
|
|
|
pub struct ParentSpeedRatioHandler;
|
|
|
|
// The server sends us a speed ratio determining the number of children we can have in the distributed network. The maximum number of children is our upload speed divided by the speed ratio.
|
|
impl MessageHandler<ServerMessage> for ParentSpeedRatioHandler {
|
|
fn get_code(&self) -> u32 {
|
|
84
|
|
}
|
|
|
|
fn handle(&self, message: &mut Message, _sender: Sender<ServerMessage>) {
|
|
let number = message.read_int32();
|
|
debug!("Parent speed ratio: {}", number);
|
|
}
|
|
}
|