await_message

Function await_message 

Source
pub fn await_message() -> Result<Message, SendError>
Expand description

Await the next message sent to this process. The runtime will handle the queueing of incoming messages, and calling this function will provide the next one. Interwoven with incoming messages are errors from the network. If your process attempts to send a message to another node, that message may bounce back with a SendError. Those should be handled here.

Example:

use hyperware_process_lib::{await_message, println};

loop {
    match await_message() {
        Ok(msg) => {
            println!("Received message: {:?}", msg);
            // Do something with the message
        }
        Err(send_error) => {
            println!("Error sending message: {:?}", send_error);
        }
    }
}