DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

bf7a23bf54d4ccf81abf745a8dc8adae6e0ee455 — Jonni Liljamo 2 years ago d9173a7
Print API check to console instead of stdout
1 files changed, 9 insertions(+), 2 deletions(-)

M sdbclient/src/plugins/connection_check/mod.rs
M sdbclient/src/plugins/connection_check/mod.rs => sdbclient/src/plugins/connection_check/mod.rs +9 -2
@@ 10,6 10,7 @@ use bevy::{
    prelude::*,
    tasks::{AsyncComputeTaskPool, Task},
};
use bevy_console::PrintConsoleLine;

use futures_lite::future;



@@ 44,11 45,17 @@ fn start_connection_check(mut commands: Commands, cfg_hidden: Res<CfgHidden>) {
fn handle_connection_check(
    mut commands: Commands,
    mut connection_check_tasks: Query<(Entity, &mut ConnectionCheck)>,
    mut console: EventWriter<PrintConsoleLine>,
) {
    for (entity, mut task) in &mut connection_check_tasks {
        if let Some(api_info) = future::block_on(future::poll_once(&mut task.0)) {
            info!("API connection check passed");
            info!("API version: {}", api_info.ver);
            console.send(PrintConsoleLine::new(
                "API connection check passed".to_string(),
            ));
            console.send(PrintConsoleLine::new(format!(
                "API version: {}",
                api_info.ver
            )));

            // Remove the task, since it's done now
            commands.entity(entity).remove::<ConnectionCheck>();