From 34ce15203cbe1f1ba6f4c5c7ee6b626f049653d0 Mon Sep 17 00:00:00 2001 From: Garry O'Donnell Date: Sat, 22 Apr 2023 10:12:53 +0100 Subject: [PATCH] Move task handles to components / resources --- bevy_matchbox/src/signaling.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bevy_matchbox/src/signaling.rs b/bevy_matchbox/src/signaling.rs index 9b3f1e6d..dd9e1684 100644 --- a/bevy_matchbox/src/signaling.rs +++ b/bevy_matchbox/src/signaling.rs @@ -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::{ @@ -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`]. @@ -64,7 +64,7 @@ use matchbox_signaling::{ /// } /// ``` #[derive(Debug, Resource)] -pub struct MatchboxServer; +pub struct MatchboxServer(Task>); impl From> for MatchboxServer where @@ -80,8 +80,8 @@ where impl From 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) } }