Skip to content

Commit

Permalink
feat: Add socket to NetworkInfo (#390)
Browse files Browse the repository at this point in the history
Expose socket via `NetworkInfo` (resource managed by net session
runner).

`NetworkMatchSocket` resource only exists in menu session. This change
makes it easier to get socket from game session.
  • Loading branch information
MaxCWhitehead committed Apr 22, 2024
1 parent cf6a57f commit b7db196
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion framework_crates/bones_framework/src/networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,18 @@ pub enum SocketTarget {
}

/// Resource updated each frame exposing current frame and last confirmed of online session.
#[derive(HasSchema, Copy, Clone, Default)]
#[derive(HasSchema, Clone)]
#[schema(no_default)]
pub struct NetworkInfo {
/// Current frame of simulation step
pub current_frame: i32,

/// Last confirmed frame by all clients.
/// Anything that occurred on this frame is agreed upon by all clients.
pub last_confirmed_frame: i32,

/// Socket
pub socket: BoxedNonBlockingSocket,
}

/// [`SessionRunner`] implementation that uses [`ggrs`] for network play.
Expand Down Expand Up @@ -511,6 +515,7 @@ where
world.insert_resource(NetworkInfo {
current_frame: self.session.current_frame(),
last_confirmed_frame: self.session.confirmed_frame(),
socket: self.socket.clone(),
});

{
Expand Down

0 comments on commit b7db196

Please sign in to comment.