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 draw_ui(&mut self, ui: &mut Ui)
pub fn draw_ui(&mut self, ui: &mut Ui)
Draw UI showing all metrics for one or all clients, without a window around it.
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.
Trait Implementations§
Source§impl<const N: usize> Default for RenetServerVisualizer<N>
impl<const N: usize> Default for RenetServerVisualizer<N>
impl<const N: usize> Resource for RenetServerVisualizer<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for RenetServerVisualizer<N>
impl<const N: usize> RefUnwindSafe for RenetServerVisualizer<N>
impl<const N: usize> Send for RenetServerVisualizer<N>
impl<const N: usize> Sync for RenetServerVisualizer<N>
impl<const N: usize> Unpin for RenetServerVisualizer<N>
impl<const N: usize> UnwindSafe for RenetServerVisualizer<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().