pub struct RenetServerVisualizer<const N: usize> { /* private fields */ }Expand description
Egui visualizer for the renet server. Draws graphs for each connected client with metrics: RTT, Packet Loss, Kbitps Sent/Received.
N: determines how many values are shown in the graph. 200 is a good value, if updated at 60 fps the graphs would hold 3 seconds of data.
Implementations§
Source§impl<const N: usize> RenetServerVisualizer<N>
impl<const N: usize> RenetServerVisualizer<N>
pub fn new(style: RenetVisualizerStyle) -> Self
Sourcepub fn add_client(&mut self, client_id: ClientId)
pub fn add_client(&mut self, client_id: ClientId)
Add a new client to keep track off. Should be called whenever a new client connected event is received.
§Usage
while let Some(event) = renet_server.get_event() {
match event {
ServerEvent::ClientConnected { client_id } => {
visualizer.add_client(client_id);
// ...
}
_ => {}
}
}Sourcepub fn remove_client(&mut self, client_id: ClientId)
pub fn remove_client(&mut self, client_id: ClientId)
Remove a client from the visualizer. Should be called whenever a client disconnected event is received.
§Usage
while let Some(event) = renet_server.get_event() {
match event {
ServerEvent::ClientDisconnected { client_id , reason } => {
visualizer.remove_client(client_id);
// ...
}
_ => {}
}
}Sourcepub fn update(&mut self, server: &RenetServer)
pub fn update(&mut self, server: &RenetServer)
Update the metrics for all connected clients. Should be called every time the server updates.
§Usage
renet_server.update(delta);
visualizer.update(&renet_server);Sourcepub fn draw_client_metrics(&self, client_id: ClientId, ui: &mut Ui)
pub fn draw_client_metrics(&self, client_id: ClientId, ui: &mut Ui)
Draw all metrics without a window or layout for the specified client.
Sourcepub fn show_window(&mut self, ctx: &Context)
pub fn show_window(&mut self, ctx: &Context)
Renders a new window with all the graphs metrics drawn. You can choose to show metrics for all connected clients or for only one chosen by a dropdown.