Benthic Logo

Optional

This component is an optional feature in the metaverse_client crate. Projects that don't require this can compile with the feature disabled in Cargo.toml

Inventory

The inventory is a core part of metaverse servers. This manages the objects your user owns and can spawn in the world.

Implementing inventory requires using the FetchInventoryDescendents2 endpoint. If you are unfamiliar with how capabilities work, visit the capabilities page on these docs.

1.

Initial Inventory information comes in with the LoginResponse, and is stored globally in the session.

2.

The initialization function triggers a RefreshInventoryEvent for the user's AgentID which is also returned from the LoginResponse. The initial request is a request for the user's inventory.

3.

The RefreshInventoryEvent waits until the capability URL has returned from the initial capability request.

4.

Make a request to the capability endpoint, using the sesion's inventory_root to make a FolderRequest, to make a request to refresh the user's inventory.

5.

The retrieved inventory is built in a sqlite database on disk, sending recursive calls until the entire hierarchy is present.

Item Metadata

The refresh inventory's recursive function reads the folder data retrieved from the endpoint from llsd. This folder object contains the folder, and item metadata of the objects in the folder.

This contains a minimal amount of information about the folder's item objects, such as the permissions, name, asset ID, description and type. These fields can be used to retreive the full item's data from the server using a different endpoint. insert_folder() is then called to add the folder and item metadata the sqlite db.

It then calls insert_items(), and then insert_categories().

At this point, the inventory's sqlite database is populated, and contains the user's inventory object metadata.

Folder Requests

The user's folders are requested from the FetchInventoryDescendents2
The XML for the request is structured like so
Folder
fetch_folders boolean
fetch_items boolean
folder_id uuid
sort_order integer
owner_id uuid
For example, a request would look like this.
Post: http://172.20.20.20:9000/371320f6-7694-4e9c-bbb9-19e56f1e1027
Header: "Content-Type", "application/llsd+xml
<?xml version="1.0" encoding="UTF-8"?>
<llsd>
  <map>
    <key>folders</key>
    <array>
      <map>
        <key>fetch_folders</key>
        <boolean>true</boolean>
        <key>fetch_items</key>
        <boolean>true</boolean>
        <key>folder_id</key>
        <uuid>5b70e16b-4e8c-e463-f9b5-16e28f1b7213</uuid>
        <key>sort_order</key>
        <integer>0</integer>
        <key>owner_id</key>
        <uuid>fb2e5541-66ba-4019-a5de-e8b9286b0914</uuid>
      </map>
    </array>
  </map>
</llsd>