Skip to content

Commit

Permalink
Move task handles to components / resources
Browse files Browse the repository at this point in the history
  • Loading branch information
garryod committed Jun 21, 2023
1 parent 3ad9faf commit 34ce152
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bevy_matchbox/src/signaling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::net::SocketAddr;
use bevy::{
ecs::system::Command,
prelude::{Commands, Resource},
tasks::IoTaskPool,
tasks::{IoTaskPool, Task},
};
pub use matchbox_signaling;
use matchbox_signaling::{
Expand All @@ -12,7 +12,7 @@ use matchbox_signaling::{
full_mesh::{FullMesh, FullMeshCallbacks, FullMeshState},
SignalingTopology,
},
SignalingCallbacks, SignalingServer, SignalingServerBuilder, SignalingState,
Error, SignalingCallbacks, SignalingServer, SignalingServerBuilder, SignalingState,
};

/// A [`SignalingServer`] as a [`Resource`].
Expand Down Expand Up @@ -64,7 +64,7 @@ use matchbox_signaling::{
/// }
/// ```
#[derive(Debug, Resource)]
pub struct MatchboxServer;
pub struct MatchboxServer(Task<Result<(), Error>>);

impl<Topology, Cb, S> From<SignalingServerBuilder<Topology, Cb, S>> for MatchboxServer
where
Expand All @@ -80,8 +80,8 @@ where
impl From<SignalingServer> for MatchboxServer {
fn from(server: SignalingServer) -> Self {
let task_pool = IoTaskPool::get();
task_pool.spawn(server.serve()).detach();
MatchboxServer
let task = task_pool.spawn(server.serve());
MatchboxServer(task)
}
}

Expand Down

0 comments on commit 34ce152

Please sign in to comment.