Skip to content

Commit 2a3640a

Browse files
committed
fix: flush packets before shutdown
This ensures that all packets, especially the disconnect message packet, are sent to the client before the server disconnects the client.
1 parent 5b5f594 commit 2a3640a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crates/hyperion-proxy/src/player.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ pub fn initiate_player_connection(
129129
packet_writer.enqueue_packet(outgoing_packet);
130130
}
131131
}
132+
133+
// Ensure that the client receives any final packets, especially a disconnect message
134+
// packet if present, when the connection is shut down. Send errors are ignored.
135+
if let Err(e) = packet_writer.flush_pending_packets().await {
136+
warn!("Error flushing packets to player: {e:?}");
137+
}
132138
});
133139

134140
tokio::task::spawn(async move {

0 commit comments

Comments
 (0)