|
|
|
/*
|
|
|
|
* Copyright (c) 2022-2023 Niko Bonnieure, Par le Peuple, NextGraph.org developers
|
|
|
|
* All rights reserved.
|
|
|
|
* Licensed under the Apache License, Version 2.0
|
|
|
|
* <LICENSE-APACHE2 or http://www.apache.org/licenses/LICENSE-2.0>
|
|
|
|
* or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
|
|
|
|
* at your option. All files in the project carrying such
|
|
|
|
* notice may not be copied, modified, or distributed except
|
|
|
|
* according to those terms.
|
|
|
|
*/
|
|
|
|
|
|
|
|
pub mod types;
|
|
|
|
|
|
|
|
pub mod errors;
|
|
|
|
|
|
|
|
pub mod broker_connection;
|
|
|
|
|
|
|
|
pub mod broker;
|
|
|
|
|
|
|
|
pub mod connection;
|
|
|
|
|
|
|
|
pub mod actor;
|
|
|
|
|
|
|
|
pub mod actors;
|
|
|
|
|
|
|
|
pub mod utils;
|
|
|
|
|
|
|
|
pub static WS_PORT: u16 = 1025;
|
|
|
|
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
|
#[wasm_bindgen]
|
|
|
|
extern "C" {
|
|
|
|
// Use `js_namespace` here to bind `console.log(..)` instead of just
|
|
|
|
// `log(..)`
|
|
|
|
#[wasm_bindgen(js_namespace = console)]
|
|
|
|
pub fn log(s: &str);
|
|
|
|
|
|
|
|
// The `console.log` is quite polymorphic, so we can bind it with multiple
|
|
|
|
// signatures. Note that we need to use `js_name` to ensure we always call
|
|
|
|
// `log` in JS.
|
|
|
|
#[wasm_bindgen(js_namespace = console, js_name = log)]
|
|
|
|
fn log_u32(a: u32);
|
|
|
|
|
|
|
|
// Multiple arguments too!
|
|
|
|
#[wasm_bindgen(js_namespace = console, js_name = log)]
|
|
|
|
fn log_many(a: &str, b: &str);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! log {
|
|
|
|
// Note that this is using the `log` function imported above during
|
|
|
|
// `bare_bones`
|
|
|
|
($($t:tt)*) => (log(&format_args!($($t)*).to_string()))
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! log {
|
|
|
|
($($t:tt)*) => (debug_print::debug_println!($($t)*))
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! sleep {
|
|
|
|
($($t:tt)*) => (gloo_timers::future::sleep($($t)*).await)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
|
|
#[macro_export]
|
|
|
|
macro_rules! sleep {
|
|
|
|
($($t:tt)*) => (std::thread::sleep($($t)*))
|
|
|
|
}
|