Build Your App

Channel

Channels are a way to send messages between the client and the server.

Usage

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);

Client

const maf = new MafClient(/* ... */);

const channel = maf.channel<string>("hello");
channel.send("Hello, world!");

See Also