use bevy::prelude::*;
use bevy_matchbox::prelude::PeerId;
use instant::Duration;
#[derive(Debug, Default, Clone, Eq, PartialEq, Hash, States)]
pub enum RtcClientStatus {
#[default]
Disconnected,
Establishing,
Connected,
}
#[derive(Resource, Default)]
pub struct RtcClientState {
pub(crate) addr: Option<String>,
pub(crate) host_peer_id: Option<PeerId>,
pub(crate) peer_id: Option<PeerId>,
pub(crate) latency: Option<Duration>,
pub(crate) smoothed_latency: Option<Duration>,
}
impl RtcClientState {
pub fn addr(&self) -> Option<&str> {
self.addr.as_deref()
}
pub fn peer_id(&self) -> Option<PeerId> {
self.peer_id
}
pub fn host_peer_id(&self) -> Option<PeerId> {
self.host_peer_id
}
pub fn latency(&self) -> Option<Duration> {
self.latency
}
pub fn smoothed_latency(&self) -> Option<Duration> {
self.smoothed_latency
}
}