instances_handle_messages

Function instances_handle_messages 

Source
pub fn instances_handle_messages(messages: &[IncomingMessage]) -> Vec<u8> 
Expand description

Have the specified instances process the provided messages

This is key functionality of the Behavior Controller API as it will kick off processing of messages for behavior instances in external behavior modules.

The following will happen after a call to instances_handle_messages:

  1. In order, Ark will extract the IncomingMessage’s address and send the message data to the correct behavior instance owned by some external behavior module.
  2. A behavior instance will then process the just received message.
  3. During the processing of a message, a behavior instance can create new OutgoingMessages that will be returned to the user of this API.

The user can then turn outgoing messages into incoming messages and repeat the above process.

Due to limitations in our bindgen, outgoing messages are returned as an encoded byte stream. OutgoingMessage acts as a decoding target to help users decode the byte stream and turn it into a usable concrete type.

The byte stream is encoded as follows:

|—– OutgoingMessage —–| |—– serialized message —–| |–– repeat..

OutgoingMessage can be safely transmuted through which you can receive the serialized message data length.