johanhelsing / matchbox

Painless peer-to-peer WebRTC networking for rust wasm (and native!)
Apache License 2.0
869 stars 72 forks source link

panic: `there is no reactor running` when starting signaling using `bevy_matchbox` #350

Closed johanhelsing closed 10 months ago

johanhelsing commented 10 months ago
use bevy::prelude::*;
use bevy_matchbox::{
    matchbox_signaling::topologies::client_server::{ClientServer, ClientServerState},
    prelude::*,
};
use std::net::Ipv4Addr;

pub struct SignalingPlugin;

impl Plugin for SignalingPlugin {
    fn build(&self, app: &mut bevy::prelude::App) {
        app.add_systems(Startup, start_signaling);
    }
}

fn start_signaling(mut commands: Commands) {
    let server: MatchboxServer = SignalingServerBuilder::new(
        (Ipv4Addr::UNSPECIFIED, 3536),
        ClientServer,
        ClientServerState::default(),
    )
    .into();

    commands.insert_resource(MatchboxServer::from(server));
}

Results in panic:

there is no reactor running, must be called from the context of a Tokio 1.x runtime