Skip to content

Commit

Permalink
update bones_framework
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Dec 4, 2024
1 parent 3f4ba7a commit 3d3605a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 62 deletions.
47 changes: 5 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion framework_crates/bones_framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ postcard = { version = "1.0", features = ["alloc"] }
rcgen = "0.12"
rustls = { version = "0.21", features = ["dangerous_configuration", "quic"] }
smallvec = "1.10"
iroh-quinn = { version = "0.11" }
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
turborand = { version = "0.10.0", features = ["atomic"] }
iroh = { workspace = true, features = ["discovery-local-network"] }
Expand Down
17 changes: 8 additions & 9 deletions framework_crates/bones_framework/src/networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,26 +110,25 @@ impl<T: DenseInput + Debug> ggrs::Config for GgrsConfig<T> {
}

/// The network endpoint used for all network communications.
static NETWORK_ENDPOINT: tokio::sync::OnceCell<iroh_net::Endpoint> =
tokio::sync::OnceCell::const_new();
static NETWORK_ENDPOINT: tokio::sync::OnceCell<iroh::Endpoint> = tokio::sync::OnceCell::const_new();

/// Get the network endpoint used for all communications.
pub async fn get_network_endpoint() -> &'static iroh_net::Endpoint {
pub async fn get_network_endpoint() -> &'static iroh::Endpoint {
NETWORK_ENDPOINT
.get_or_init(|| async move {
let secret_key = iroh_net::key::SecretKey::generate();
iroh_net::Endpoint::builder()
let secret_key = iroh::key::SecretKey::generate();
iroh::Endpoint::builder()
.alpns(vec![MATCH_ALPN.to_vec(), PLAY_ALPN.to_vec()])
.discovery(Box::new(
iroh_net::discovery::ConcurrentDiscovery::from_services(vec![
iroh::discovery::ConcurrentDiscovery::from_services(vec![
Box::new(
iroh_net::discovery::local_swarm_discovery::LocalSwarmDiscovery::new(
iroh::discovery::local_swarm_discovery::LocalSwarmDiscovery::new(
secret_key.public(),
)
.unwrap(),
),
Box::new(iroh_net::discovery::dns::DnsDiscovery::n0_dns()),
Box::new(iroh_net::discovery::pkarr::PkarrPublisher::n0_dns(
Box::new(iroh::discovery::dns::DnsDiscovery::n0_dns()),
Box::new(iroh::discovery::pkarr::PkarrPublisher::n0_dns(
secret_key.clone(),
)),
]),
Expand Down
2 changes: 1 addition & 1 deletion framework_crates/bones_framework/src/networking/lan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

use std::{net::IpAddr, time::Duration};

use iroh_net::{endpoint::get_remote_node_id, NodeAddr};
use iroh::{endpoint::get_remote_node_id, NodeAddr};
use mdns_sd::{ServiceDaemon, ServiceInfo};
use smallvec::SmallVec;
use tracing::warn;
Expand Down
4 changes: 1 addition & 3 deletions framework_crates/bones_framework/src/networking/online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ use crate::{
pub use bones_matchmaker_proto::{
GameID, LobbyId, LobbyInfo, LobbyListItem, MatchInfo, PlayerIdxAssignment, MATCH_ALPN,
};
use iroh_net::Endpoint;
use iroh_net::NodeId;
use iroh_quinn::Connection;
use iroh::{endpoint::Connection, Endpoint, NodeId};
use once_cell::sync::Lazy;
use tracing::{info, warn};

Expand Down
12 changes: 6 additions & 6 deletions framework_crates/bones_framework/src/networking/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use bones_matchmaker_proto::PLAY_ALPN;
use bytes::Bytes;
use iroh_net::NodeAddr;
use iroh::NodeAddr;
use tracing::{info, warn};

use crate::networking::get_network_endpoint;
Expand All @@ -13,7 +13,7 @@ use super::{GameMessage, NetworkSocket, SocketTarget, RUNTIME};
/// The [`NetworkSocket`] implementation.
#[derive(Debug, Clone)]
pub struct Socket {
pub connections: Vec<(u32, iroh_quinn::Connection)>,
pub connections: Vec<(u32, iroh::endpoint::Connection)>,
pub ggrs_receiver: async_channel::Receiver<(u32, GameMessage)>,
pub reliable_receiver: async_channel::Receiver<(u32, Vec<u8>)>,
pub player_idx: u32,
Expand All @@ -23,7 +23,7 @@ pub struct Socket {
}

impl Socket {
pub fn new(player_idx: u32, connections: Vec<(u32, iroh_quinn::Connection)>) -> Self {
pub fn new(player_idx: u32, connections: Vec<(u32, iroh::endpoint::Connection)>) -> Self {
let (ggrs_sender, ggrs_receiver) = async_channel::unbounded();
let (reliable_sender, reliable_receiver) = async_channel::unbounded();

Expand Down Expand Up @@ -129,7 +129,7 @@ impl Socket {
}
}

fn get_connection(&self, idx: u32) -> &iroh_quinn::Connection {
fn get_connection(&self, idx: u32) -> &iroh::endpoint::Connection {
debug_assert!(idx < self.player_count);
// TODO: if this is too slow, optimize storage
self.connections
Expand Down Expand Up @@ -217,8 +217,8 @@ pub(super) async fn establish_peer_connections(
player_idx: u32,
player_count: u32,
peer_addrs: Vec<(u32, NodeAddr)>,
conn: Option<iroh_quinn::Connection>,
) -> anyhow::Result<Vec<(u32, iroh_quinn::Connection)>> {
conn: Option<iroh::endpoint::Connection>,
) -> anyhow::Result<Vec<(u32, iroh::endpoint::Connection)>> {
let mut peer_connections = Vec::new();
let had_og_conn = conn.is_some();
if let Some(conn) = conn {
Expand Down

0 comments on commit 3d3605a

Please sign in to comment.