summaryrefslogtreecommitdiff
path: root/WebInterface/wasm/webhogg/src/lib.rs
blob: 9d052cd6b19834b1b79de78c004fe09e140dc6fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
mod client_logger;
mod webhogg_exception;
mod page;
mod canvas;
mod app;

use wasm_bindgen::prelude::*;
use app::WebhoggApplication as App;
use web_sys::Worker;

#[macro_use]
extern crate log;

fn run_application() {
    match App::new().and_then(|app| app.run()) {
        Ok(_) => info!("program terminated successfully"),
        Err(e) => error!("program terminated with failure > {}", e)
    }
}

#[wasm_bindgen]
pub fn game_logic_entry(worker: web_sys::Worker) {
    client_logger::init_logger();

    info!("game logic initialisation");
    info!("js value: {:?}", worker);
    worker.post_message(&wasm_bindgen::JsValue::from_str("msg frm wasm_gLe")).unwrap();
}

#[wasm_bindgen]
pub fn graphics_entry() {
    client_logger::init_logger();

    info!("graphics initialisation");
}

pub fn entry2() {
    client_logger::init_logger();

    info!("begin running wasm application");

    run_application()
}