~starkingdoms/starkingdoms

443b64e76daa284a98fb22c74c1a878f92546229 — core 2 years ago 4613985
fixup! fixup! fixup
2 files changed, 8 insertions(+), 8 deletions(-)

M client/src/lib.rs
M web/play.html
M client/src/lib.rs => client/src/lib.rs +7 -7
@@ 31,7 31,7 @@ extern {

#[wasm_bindgen]
pub async fn rust_init(gateway: &str, username: &str) -> Result<(), JsError> {
    update_status("Starting logger...");
    set_status("Starting logger...");

    console_log::init_with_level(Level::Debug).unwrap();



@@ 76,13 76,13 @@ pub async fn main(gateway: &str, username: &str, backoff: i32) -> Result<(), Box
    wait_for(sleep(backoff * backoff * 1000)).await;

    if backoff > MAX_CONNECTION_TRIES {
        update_status("Connection to server failed");
        set_status("Connection to server failed");
        return Err("Hit backoff limit during reconnection attempt".into());
    }
    if backoff == 1 {
        update_status("Connecting to server...");
        set_status("Connecting to server...");
    } else {
        update_status(&format!("Connection failed, retrying... (try {}/10)", backoff));
        set_status(&format!("Connection failed, retrying... (try {}/10)", backoff));
    }

    info!("FAST CONNECT: {}", gateway);


@@ 112,7 112,7 @@ pub async fn main(gateway: &str, username: &str, backoff: i32) -> Result<(), Box

    trace!("Split stream, handshaking with server");

    update_status("Handshaking with server...");
    set_status("Handshaking with server...");

    send!(client_data.tx, &MessageC2S::Hello {
        next_state: State::Play,


@@ 144,7 144,7 @@ pub async fn main(gateway: &str, username: &str, backoff: i32) -> Result<(), Box

    CLIENT.write()?.client_data = Some(client_data);

    update_status(&format!("Connected! Username: {}", username));
    set_status(&format!("Connected! Username: {}", username));

    Ok(())
}


@@ 198,7 198,7 @@ pub async fn update_socket() -> Result<(), JsError> {
}

#[wasm_bindgen]
pub fn update_status(new_status: &str) {
pub fn set_status(new_status: &str) {
    let window: Window = web_sys::window().expect("no global `window` exists");
    let document = window.document().expect("should have a document on window");
    let status = document.get_element_by_id("status").expect("statusbox does not exist");

M web/play.html => web/play.html +1 -1
@@ 21,7 21,7 @@
        <script type="module">
            // If you're getting build errors here | you need to run `just build_client_bundle` first, to compile client code
            //                                     v
            import init, { rust_init, send_chat, update_socket, update_status } from "./dist/client.js";
            import init, { rust_init, send_chat, update_socket } from "./dist/starkingdoms_client.js";
            init().then(() => {
                const urlSearchParams = new URLSearchParams(window.location.search);