Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
raffaeleragni committed Jan 7, 2024
1 parent e24e38d commit 8b051ce
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/client/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use bevy::{prelude::*, utils::HashSet};
use bevy_renet::renet::{DefaultChannel, RenetClient};

use crate::{
lib_priv::SyncTrackerRes, networking::assets::SyncAssetTransfer, proto::Message,
proto::SyncAssetType, binreflect::reflect_to_bin, SyncMark, SyncUp,
binreflect::reflect_to_bin, lib_priv::SyncTrackerRes, networking::assets::SyncAssetTransfer,
proto::Message, proto::SyncAssetType, SyncMark, SyncUp,
};

pub(crate) fn track_spawn_client(
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
**state is in development**
*/

mod binreflect;
mod bundle_fix;
mod client;
mod lib_priv;
mod logging;
mod networking;
mod proto;
mod binreflect;
mod server;

pub mod prelude {
Expand Down
6 changes: 3 additions & 3 deletions src/lib_priv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use bevy::{
use bevy_renet::renet::ClientId;

use crate::{
bundle_fix::BundleFixPlugin, client::ClientSyncPlugin, proto::AssId, binreflect::bin_to_reflect,
server::ServerSyncPlugin, ClientPlugin, ServerPlugin, SyncComponent, SyncDown, SyncExclude,
SyncMark, SyncPlugin, SyncUp,
binreflect::bin_to_reflect, bundle_fix::BundleFixPlugin, client::ClientSyncPlugin,
proto::AssId, server::ServerSyncPlugin, ClientPlugin, ServerPlugin, SyncComponent, SyncDown,
SyncExclude, SyncMark, SyncPlugin, SyncUp,
};

#[derive(PartialEq, Eq, Hash)]
Expand Down
16 changes: 10 additions & 6 deletions src/networking/assets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,26 @@ pub(crate) struct SyncAssetTransfer {

impl SyncAssetTransfer {
pub(crate) fn new(addr: IpAddr, port: u16, max_transfer: usize) -> Self {
let bind = SocketAddr::new(addr, port);
let base_url = format!("http://{}:{}", addr, port);
debug!("Starting asset server on {}", base_url);
let server = Server::http(SocketAddr::new(addr, port)).unwrap();

let server_pool = ThreadPool::new(128);
let download_pool = ThreadPool::new(127);

let meshes = Arc::new(RwLock::new(HashMap::<Uuid, Vec<u8>>::new()));
let meshes_to_apply = Arc::new(RwLock::new(HashMap::<Uuid, Vec<u8>>::new()));

let (server_tx, server_rx) = channel::<Request>();
let server = Server::http(bind).unwrap();
let result = Self {
base_url: format!("http://{}:{}", addr, port),
base_url,
server_pool,
download_pool,
meshes,
meshes_to_apply,
max_transfer,
};

let (server_tx, server_rx) = channel::<Request>();
result.server_pool.execute(move || {
for request in server.incoming_requests() {
debug!("Queuing response to {}", request.url());
Expand Down Expand Up @@ -117,7 +121,7 @@ impl SyncAssetTransfer {
loop {
match lock {
Ok(mut map) => {
debug!("Received mesh {}", id);
debug!("Received mesh {} with size {}", id, len);
map.insert(id, bytes);
break;
}
Expand Down Expand Up @@ -158,7 +162,6 @@ impl SyncAssetTransfer {
continue;
};

debug!("Responding to {}", url);
let Ok(meshesmap) = meshes.read() else {
request
.respond(Response::from_string("").with_status_code(449))
Expand All @@ -171,6 +174,7 @@ impl SyncAssetTransfer {
.unwrap_or(());
continue;
};
debug!("Responding to {} with size {}", url, mesh.len());
request
.respond(Response::from_data(mesh.clone()).with_chunked_threshold(max_size))
.unwrap_or(());
Expand Down
4 changes: 2 additions & 2 deletions src/server/initial_sync.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::error::Error;

use crate::{
lib_priv::SyncTrackerRes, networking::assets::SyncAssetTransfer, proto::Message,
proto::SyncAssetType, binreflect::reflect_to_bin, SyncDown,
binreflect::reflect_to_bin, lib_priv::SyncTrackerRes, networking::assets::SyncAssetTransfer,
proto::Message, proto::SyncAssetType, SyncDown,
};
use bevy::utils::Uuid;
use bevy::{prelude::*, utils::HashSet};
Expand Down
2 changes: 1 addition & 1 deletion src/server/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use bevy::{prelude::*, utils::HashSet};
use bevy_renet::renet::{DefaultChannel, RenetServer};

use crate::{
binreflect::reflect_to_bin,
lib_priv::{SyncClientGeneratedEntity, SyncTrackerRes},
networking::assets::SyncAssetTransfer,
proto::Message,
proto::SyncAssetType,
binreflect::reflect_to_bin,
SyncDown, SyncMark,
};

Expand Down

0 comments on commit 8b051ce

Please sign in to comment.