Add a login loop when the password is wrong
This commit is contained in:
parent
103eb7835a
commit
d36274cd33
@ -20,23 +20,25 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn run() -> Result<(), JsValue> {
|
fn run() -> Result<(), JsValue> {
|
||||||
|
spawn_local(async move {
|
||||||
|
let vnc = loop {
|
||||||
// connect
|
// connect
|
||||||
let url = format!(
|
let url = format!(
|
||||||
"{scheme}://{host}/websockify",
|
"{scheme}://{host}/websockify",
|
||||||
scheme = if web_sys::window()
|
scheme = if web_sys::window()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.location()
|
.location()
|
||||||
.protocol()?
|
.protocol()
|
||||||
|
.unwrap()
|
||||||
.starts_with("https")
|
.starts_with("https")
|
||||||
{
|
{
|
||||||
"wss"
|
"wss"
|
||||||
} else {
|
} else {
|
||||||
"ws"
|
"ws"
|
||||||
},
|
},
|
||||||
host = web_sys::window().unwrap().location().host()?
|
host = web_sys::window().unwrap().location().host().unwrap()
|
||||||
);
|
);
|
||||||
|
|
||||||
spawn_local(async move {
|
|
||||||
// start websocket
|
// start websocket
|
||||||
let (_ws, wsio) = WsMeta::connect(url, vec!["binary"]).await.unwrap();
|
let (_ws, wsio) = WsMeta::connect(url, vec!["binary"]).await.unwrap();
|
||||||
|
|
||||||
@ -59,11 +61,13 @@ fn run() -> Result<(), JsValue> {
|
|||||||
|
|
||||||
if vnc.is_err() {
|
if vnc.is_err() {
|
||||||
if let Err(e) = vnc {
|
if let Err(e) = vnc {
|
||||||
let msg = format!("connect error {:?}\nRe log in", e);
|
let msg = format!("connect error {:?}\nRelog in please", e);
|
||||||
alert(&msg);
|
alert(&msg);
|
||||||
panic!("{}", msg);
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break vnc;
|
||||||
|
};
|
||||||
|
|
||||||
let vnc = vnc.unwrap().finish().unwrap();
|
let vnc = vnc.unwrap().finish().unwrap();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user