clean up ICE config (#1072)

This commit is contained in:
Logan McNaughton
2026-06-13 19:29:36 +02:00
committed by GitHub
parent ae7bac65d5
commit d6da1656b8
2 changed files with 12 additions and 3 deletions
+6 -1
View File
@@ -169,6 +169,8 @@ pub fn run(args: Args, arg_count: usize) -> std::io::Result<()> {
let mut shutdown_tx = None;
let mut usb_handle = None;
let ice_config_path = dirs.cache_dir.join("ice_config.json");
if let Some(server_addr) = args.netplay_server_addr
&& let Some(player_number) = args.netplay_player_number
&& let Some(number_of_players) = args.netplay_number_of_players
@@ -179,6 +181,7 @@ pub fn run(args: Args, arg_count: usize) -> std::io::Result<()> {
player_number,
number_of_players,
input_delay,
ice_config_path.clone(),
device::cart::rom::is_system_pal(&rom_contents),
);
if device.netplay.is_none() {
@@ -253,7 +256,9 @@ pub fn run(args: Args, arg_count: usize) -> std::io::Result<()> {
#[cfg(not(target_os = "android"))]
retroachievements::shutdown_client();
if device.netplay.is_none() {
if device.netplay.is_some() {
netplay::close(ice_config_path);
} else {
for i in 0..4 {
if device.ui.config.input.transfer_pak[i]
&& !device.ui.config.input.gb_ram_path[i].is_empty()
+6 -2
View File
@@ -351,14 +351,14 @@ pub fn init(
player_number: usize,
number_of_players: usize,
input_delay: usize,
ice_config_path: std::path::PathBuf,
pal: bool,
) -> Option<Netplay> {
let mut builder = matchbox_socket::WebRtcSocketBuilder::new(server_addr)
.add_unreliable_channel()
.add_reliable_channel();
if let ice_config_path = ui::get_dirs().cache_dir.join("ice_config.json")
&& let Ok(ice_config) = std::fs::read(&ice_config_path)
if let Ok(ice_config) = std::fs::read(&ice_config_path)
&& let Ok(ice_config) = serde_json::from_slice::<RtcIceServerConfig>(&ice_config)
{
builder = builder.ice_server(matchbox_socket::RtcIceServerConfig {
@@ -472,3 +472,7 @@ pub fn init(
messages: std::collections::HashMap::new(),
})
}
pub fn close(ice_config_path: std::path::PathBuf) {
let _ = std::fs::remove_file(ice_config_path);
}