Skip to content

Commit

Permalink
NetworkPeerAddress component
Browse files Browse the repository at this point in the history
  • Loading branch information
Veritius committed Apr 28, 2024
1 parent f6a33c3 commit 37d501b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions stardust/src/connections/peer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! "Peers" aka other computers over the network.
use std::time::Instant;
use std::{net::SocketAddr, time::Instant};
use bevy::prelude::*;

/// An active connection to a remote peer.
Expand All @@ -13,10 +13,11 @@ use bevy::prelude::*;
/// Instead, it should be managed by transport layer plugins.
///
/// Entities with this component may also have the following components:
/// - [`NetworkMessages`](crate::messages::NetworkMessages), relating to messages
/// - [`NetworkPeerUid`], relating to persistent data
/// - [`NetworkPeerLifestage`], relating to connection state
/// - [`NetworkSecurity`](super::security::NetworkSecurity), relating to encryption
/// - [`NetworkMessages`](crate::messages::NetworkMessages), relating to messages.
/// - [`NetworkPeerAddress`], relating to IP address data.
/// - [`NetworkPeerUid`], relating to persistent data.
/// - [`NetworkPeerLifestage`], relating to connection state.
/// - [`NetworkSecurity`](super::security::NetworkSecurity), relating to encryption.
#[derive(Debug, Component, Reflect)]
#[reflect(Debug, Component)]
pub struct NetworkPeer {
Expand Down Expand Up @@ -84,6 +85,10 @@ pub enum NetworkPeerLifestage {
Closed,
}

/// The IP address of a network peer, if it has one.
#[derive(Component, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct NetworkPeerAddress(pub SocketAddr);

/// A unique identifier for a [`NetworkPeer`], to store persistent data across multiple connections.
/// This component should only be constructed by the app developer, but can be read by any plugins.
///
Expand Down

0 comments on commit 37d501b

Please sign in to comment.