Build Your App
Channels are a way to send messages between the client and the server.
fn build() -> App {
App::builder()
.on_connect(on_connect)
.background(|app: App| async move {
let mut chan = app.channel::<String>("hello");
loop {
match chan.recv().await {
Ok(msg) => println!("got message! `{msg}`"),
Err(e) => println!("failed to receive message: {e}"),
}
}
})
.build()
}
maf::register!(build);
const maf = new MafClient(/* ... */);
const channel = maf.channel<string>("hello");
channel.send("Hello, world!");