Fix not "disconnecting" (hopefully on mobile too)
Sometimes the player would not disconnect from the Network Multiplayer session on the back-end. Seems to work on PC browsers, not so well with moblie browsers. This commit hopefully fixes this for mobile browsers.
This commit is contained in:
parent
57b782ad4d
commit
2aa4200835
2 changed files with 9 additions and 4 deletions
|
@ -9,7 +9,7 @@ edition = "2021"
|
||||||
yew = "0.19"
|
yew = "0.19"
|
||||||
log = "0.4.6"
|
log = "0.4.6"
|
||||||
wasm-logger = "0.2.0"
|
wasm-logger = "0.2.0"
|
||||||
web-sys = { version = "0.3.56", features = ["Window", "Document", "Element", "Request", "RequestInit", "Headers", "RequestMode", "Response", "ReadableStream"] }
|
web-sys = { version = "0.3.56", features = ["Window", "Document", "Element", "Request", "RequestInit", "Headers", "RequestMode", "Response", "ReadableStream", "AddEventListenerOptions", "EventTarget"] }
|
||||||
js-sys = "0.3.56"
|
js-sys = "0.3.56"
|
||||||
oorandom = "11.1.3"
|
oorandom = "11.1.3"
|
||||||
wasm-bindgen = { version = "0.2.79", features = ["serde-serialize"] }
|
wasm-bindgen = { version = "0.2.79", features = ["serde-serialize"] }
|
||||||
|
|
|
@ -29,7 +29,7 @@ use std::rc::Rc;
|
||||||
|
|
||||||
use js_sys::{Function, Promise};
|
use js_sys::{Function, Promise};
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
use web_sys::{Document, Response};
|
use web_sys::{AddEventListenerOptions, Document, Response};
|
||||||
|
|
||||||
use serde_json::Value as SerdeJSONValue;
|
use serde_json::Value as SerdeJSONValue;
|
||||||
|
|
||||||
|
@ -1238,12 +1238,17 @@ impl Component for Wrapper {
|
||||||
let binded_func =
|
let binded_func =
|
||||||
outer_function.bind1(&outer_function, &resolve);
|
outer_function.bind1(&outer_function, &resolve);
|
||||||
window
|
window
|
||||||
.add_event_listener_with_callback("pagehide", &binded_func)
|
.add_event_listener_with_callback_and_add_event_listener_options(
|
||||||
|
"pagehide",
|
||||||
|
&binded_func,
|
||||||
|
AddEventListenerOptions::new().capture(true).once(true)
|
||||||
|
)
|
||||||
.expect("Should be able to set \"pagehide\" callback");
|
.expect("Should be able to set \"pagehide\" callback");
|
||||||
window
|
window
|
||||||
.add_event_listener_with_callback(
|
.add_event_listener_with_callback_and_add_event_listener_options(
|
||||||
"beforeunload",
|
"beforeunload",
|
||||||
&binded_func,
|
&binded_func,
|
||||||
|
AddEventListenerOptions::new().capture(true).once(true)
|
||||||
)
|
)
|
||||||
.expect("Should be able to set \"beforeunload\" callback");
|
.expect("Should be able to set \"beforeunload\" callback");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue