Add network link to ue-server implementation #13
@ -39,7 +39,7 @@ pub struct MessageReader {
|
||||
is_broken: bool,
|
||||
reading_state: ReadingState,
|
||||
dkanus marked this conversation as resolved
Outdated
Ggg_123
commented
Outdated
Review
> 4 bytes
u32? i32? BEi32? LEi32?
|
||||
read_bytes: usize,
|
||||
buffer: [u8; 4],
|
||||
length_buffer: [u8; 4],
|
||||
current_message_length: usize,
|
||||
current_message: Vec<u8>,
|
||||
dkanus marked this conversation as resolved
Outdated
Ggg_123
commented
buffer => length_buffer, since it's used only for storing length bytes buffer => length_buffer, since it's used only for storing length bytes
dkanus
commented
Agreed Agreed
|
||||
read_messages: VecDeque<String>,
|
||||
@ -63,7 +63,7 @@ impl MessageReader {
|
||||
is_broken: false,
|
||||
Ggg_123
commented
Missing else? Condition seems important. Missing else? Condition seems important.
|
||||
reading_state: ReadingState::Head,
|
||||
read_bytes: 0,
|
||||
buffer: [0; 4],
|
||||
length_buffer: [0; 4],
|
||||
current_message_length: 0,
|
||||
// Will be recreated with `with_capacity` in `push_byte()`
|
||||
current_message: Vec::new(),
|
||||
Ggg_123
commented
Why? Why?
|
||||
@ -88,18 +88,18 @@ impl MessageReader {
|
||||
}
|
||||
}
|
||||
ReadingState::ReceivedBytes => {
|
||||
self.buffer[self.read_bytes] = input;
|
||||
self.length_buffer[self.read_bytes] = input;
|
||||
Ggg_123
commented
Why is it a separate function, and not inside send/flush? Why is it a separate function, and not inside send/flush?
When should I call it?
|
||||
self.read_bytes += 1;
|
||||
if self.read_bytes >= UE_RECEIVED_FIELD_SIZE {
|
||||
self.ue_received_bytes += array_of_u8_to_u32(self.buffer) as u64;
|
||||
self.ue_received_bytes += array_of_u8_to_u32(self.length_buffer) as u64;
|
||||
self.change_state(ReadingState::Head);
|
||||
}
|
||||
}
|
||||
ReadingState::Length => {
|
||||
self.buffer[self.read_bytes] = input;
|
||||
self.length_buffer[self.read_bytes] = input;
|
||||
self.read_bytes += 1;
|
||||
if self.read_bytes >= UE_LENGTH_FIELD_SIZE {
|
||||
self.current_message_length = array_of_u8_to_u32(self.buffer) as usize;
|
||||
self.current_message_length = array_of_u8_to_u32(self.length_buffer) as usize;
|
||||
self.change_state(ReadingState::Payload);
|
||||
Ggg_123
commented
// todo - add IP support, since 0.0.0.0 is subjective (make it default, but changeable) // todo - add IP support, since 0.0.0.0 is subjective (make it default, but changeable)
|
||||
if self.current_message_length > MAX_UE_MESSAGE_LENGTH {
|
||||
dkanus marked this conversation as resolved
Outdated
Ggg_123
commented
"1 as usize" => "1usize" "1 as usize" => "1usize"
Or just remove.
|
||||
self.is_broken = true;
|
||||
dkanus marked this conversation as resolved
Outdated
Ggg_123
commented
Move this line below error checking, since it contains early exit Move this line below error checking, since it contains early exit
dkanus
commented
Agreed. Agreed.
|
||||
|
Loading…
Reference in New Issue
Block a user