Add network link to ue-server implementation #13

Open
dkanus wants to merge 23 commits from feature_link into master
Showing only changes of commit f118767e3f - Show all commits

View File

@ -39,7 +39,7 @@ pub struct MessageReader {
is_broken: bool,
reading_state: ReadingState,
dkanus marked this conversation as resolved Outdated

4 bytes
u32? i32? BEi32? LEi32?

> 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

buffer => length_buffer, since it's used only for storing length bytes

buffer => length_buffer, since it's used only for storing length bytes

Agreed

Agreed
read_messages: VecDeque<String>,
@ -63,7 +63,7 @@ impl MessageReader {
is_broken: false,
Review

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(),
Review

Why?

Why?
@ -88,18 +88,18 @@ impl MessageReader {
}
}
ReadingState::ReceivedBytes => {
self.buffer[self.read_bytes] = input;
self.length_buffer[self.read_bytes] = input;
Review

Why is it a separate function, and not inside send/flush?
When should I call it?

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);
Review

// 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

"1 as usize" => "1usize"
Or just remove.

"1 as usize" => "1usize" Or just remove.
self.is_broken = true;
dkanus marked this conversation as resolved Outdated

Move this line below error checking, since it contains early exit

Move this line below error checking, since it contains early exit

Agreed.

Agreed.