Add popup when client disconnects

This commit is contained in:
Sofia 2026-07-23 19:40:22 +03:00
parent 1fda2f821e
commit 5e6c8b3fac

View File

@ -1,10 +1,12 @@
use std::net::SocketAddr; use std::net::SocketAddr;
use godot::obj::Singleton;
use teanet::PeerMessage; use teanet::PeerMessage;
use crate::{ use crate::{
game_manager::{Game, GameManager, GameOption}, game_manager::{Game, GameManager, GameOption},
net::network_manager::{NetworkManager, Package, PeerKind}, net::network_manager::{NetworkManager, Package, PeerKind},
popup_queue::{Popup, PopupQueue},
ui::cli::{CliColor, CommandLinePanel}, ui::cli::{CliColor, CommandLinePanel},
}; };
@ -32,6 +34,18 @@ impl NetworkManager {
format!("Error with connection: {}", err), format!("Error with connection: {}", err),
CliColor::Error, CliColor::Error,
); );
PopupQueue::singleton().bind_mut().queue(Popup {
title: "Error".to_owned(),
message: err.to_string(),
ok: true,
});
} else {
PopupQueue::singleton().bind_mut().queue(Popup {
title: "Disconnected".to_owned(),
message: "disconnected".to_owned(),
ok: true,
});
} }
peer.close(); peer.close();
} }