Skip to content

Commit 6909469

Browse files
committed
fixed packet handling
1 parent 597c128 commit 6909469

File tree

2 files changed

+16
-27
lines changed

2 files changed

+16
-27
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/chat_client.rs

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl ChatClient {
374374
warn!("├─>{} Sending to Simulation Controller...", "!!!".yellow());
375375

376376
self.controller_send
377-
.send(DroneEvent::PacketDropped(packet))
377+
.send(ChatClientEvent::ControllerShortcut(packet))
378378
.unwrap();
379379

380380
warn!(
@@ -407,7 +407,7 @@ impl ChatClient {
407407
warn!("├─>{} Sending to Simulation Controller...", "!!!".yellow());
408408

409409
self.controller_send
410-
.send(DroneEvent::PacketDropped(packet))
410+
.send(ChatClientEvent::ControllerShortcut(packet))
411411
.unwrap();
412412

413413
warn!(
@@ -423,24 +423,13 @@ impl ChatClient {
423423
}
424424

425425
fn handle_ack_nack(&mut self, packet: Packet) {
426-
if let PacketType::Nack(nack) = packet.clone().pack_type {
427-
warn!(
428-
"{} [ ChatClient {} ]: received a {}",
429-
"!!!".yellow(),
430-
self.id,
431-
packet.pack_type,
432-
);
433-
// Send a nack to the previous node
434-
self.send_nack(packet, None, NackType::Dropped);
435-
} else {
436-
warn!(
437-
"{} [ ChatClient {} ]: received a {}",
438-
"!!!".yellow(),
439-
self.id,
440-
packet.pack_type,
441-
);
442-
self.forward_packet(packet);
443-
}
426+
warn!(
427+
"{} [ ChatClient {} ]: received a {}",
428+
"!!!".yellow(),
429+
self.id,
430+
packet.pack_type,
431+
);
432+
self.forward_packet(packet);
444433
}
445434

446435
fn send_nack(&self, mut packet: Packet, fragment: Option<Fragment>, nack_type: NackType) {
@@ -490,7 +479,7 @@ impl ChatClient {
490479

491480
//there is an error in sending the packet, the drone should send the packet to the simulation controller
492481
self.controller_send
493-
.send(DroneEvent::PacketDropped(packet))
482+
.send(ChatClientEvent::ControllerShortcut(packet))
494483
.unwrap();
495484
warn!(
496485
"└─>{} [ ChatClient {} ]: sent A Nack to the Simulation Controller",
@@ -526,7 +515,7 @@ impl ChatClient {
526515

527516
// Send to the simulation controller
528517
self.controller_send
529-
.send(DroneEvent::PacketDropped(packet))
518+
.send(ChatClientEvent::ControllerShortcut(packet))
530519
.unwrap();
531520
warn!(
532521
"└─>{} [ ChatClient {} ]: sent A Nack to the Simulation Controller",
@@ -713,7 +702,7 @@ impl ChatClient {
713702
warn!("├─>{} Sending to Simulation Controller...", "!!!".yellow());
714703

715704
self.controller_send
716-
.send(DroneEvent::PacketDropped(new_packet))
705+
.send(ChatClientEvent::ControllerShortcut(new_packet))
717706
.unwrap();
718707

719708
warn!(
@@ -736,7 +725,7 @@ impl ChatClient {
736725

737726
// Send the packet to the simulation controller
738727
self.controller_send
739-
.send(DroneEvent::PacketDropped(new_packet))
728+
.send(ChatClientEvent::ControllerShortcut(new_packet))
740729
.unwrap();
741730

742731
warn!(
@@ -787,7 +776,7 @@ impl ChatClient {
787776
warn!("├─>{} Sending to Simulation Controller...", "!!!".yellow());
788777

789778
self.controller_send
790-
.send(DroneEvent::PacketDropped(new_packet))
779+
.send(ChatClientEvent::ControllerShortcut(new_packet))
791780
.unwrap();
792781

793782
warn!(
@@ -809,7 +798,7 @@ impl ChatClient {
809798
warn!("├─>{} Sending to Simulation Controller...", "!!!".yellow());
810799

811800
self.controller_send
812-
.send(DroneEvent::PacketDropped(new_packet))
801+
.send(ChatClientEvent::ControllerShortcut(new_packet))
813802
.unwrap();
814803

815804
warn!(

0 commit comments

Comments
 (0)