# Item files, the gate and the licence

A manifest names items; drawing them needs the items' files: meshes, textures, clips. The SDK never ships them. It
reads them at run time from the sources you give the context, in order, and the first that has a file wins. The
licence file from your download opens the context and, with the gate as a source, lets it stream items for your app.

```sh
sona render seed:vega -o vega.png --gate
```

The commands on the concept pages are the `sona` tool's, which installs apart from the SDK
([installing the tools](../guides/installer.md)). `seed:vega` is one of its four sample avatars (`atlas`,
`vega`, `juno` and `cutout`); a manifest file or base64 text works in its place. `--dir ~/dump` reads the item files
from a folder of your own; `--gate` streams them from 360sona instead, with the licence of your download
(`--sdk sdk` finds it there).

## The sources

`sona_config.sources` holds up to `SONA_MAX_SOURCES` (4), asked in order:

| Source | `kind` | `location` | Use it when |
|---|---|---|---|
| The 360sona gate | `SONA_SOURCE_GATE` | `NULL`: https://360sona.com/g | Items should stream over https for your app id, with nothing to install |
| An asset folder | `SONA_SOURCE_DIR` | the folder | You keep the item files yourself, laid out as the gate serves them |
| A console's storage | `SONA_SOURCE_CONSOLE` | a Content root (`uda0:/Content`) or a PC path to one | The program runs on an Xbox 360, or reads a console's Content tree |
| Your own reader | `SONA_SOURCE_CUSTOM` | `custom` | The files are in your own archive, package or network layer |

What is read is decoded on worker threads and kept in a memory cache that counts against the context's budget
([memory](../concepts.md#memory)); an item no avatar uses any more is kept for reuse and dropped oldest first. A
folder or a console source works offline. With the gate, an item read once stays in the cache for the run.

On the command line `--gate` is the gate and `--dir <folder>` an asset folder (up to four, or `$SONA_DIR`)
([CLI reference](../reference/cli.md#global-options)). The sample programs of the download (`samples/`) and
the templates stream from the gate with the licence of your download, so their commands in these pages give no
folder; `--dir "<asset folder>"` reads one instead. With no network they stop at once and say so. Their
`--cast devs-cast.json` is the [sample avatars](../install.md#sample-avatars).

## The gate

The gate is 360sona's item server. It answers only a program with a licence for an app, and it streams the files of
the items asked for by id, so a game reads what its avatars wear and nothing more. Each app has a daily allowance per
address: 10,000 items and 100,000 answers ([limits](../limits.md)). A web page reaches the gate through the bridge,
an iframe the web SDK opens on 360sona.com, so its items never sit in your page's own files.

When the gate cannot be reached the code is `SONA_E_GATE`
([troubleshooting](../troubleshooting.md#error-codes)).

## The licence

Each download carries `sona-licence.json`: your app id, the build id, the platforms it is for and its version, signed
with 360sona's release key. The context checks it when it opens:

| Result of `sona_open` | Means |
|---|---|
| `SONA_E_LICENCE` | The file is missing, damaged or another app's, or the app has not accepted the SDK Licence |
| `SONA_E_PLATFORM` | The download was made for other platforms |
| `SONA_E_APP` | The app was turned off |
| `SONA_E_BUILD` | This build was revoked |

With the gate as a source, the context also checks its build with 360sona in the background. A revoked build or an
app that was turned off closes the gate source and raises `SONA_EVENT_ERROR`; folder and console sources need only
the licence file and keep working offline ([signed releases and revocation](../guides/release.md)).

Each library in a download is stamped with your app and its build. Use your own download, and ship it only inside
your game ([licence and credit](../licence.md#your-download)).

## A source of your own

`SONA_SOURCE_CUSTOM` hands every read to your code: a `sona_source` with a `read` callback that gets a request and
completes it, from any thread, with the bytes or an error. It is how a game reads items from its own pack file, or
proxies the gate through its own server. The reference has the callback's rules
([asset sources](../reference.md#asset-sources)).

## Related

- [Installing](../install.md#avatar-files): the sources in a first program.
- [Untrusted files, long sessions](../guides/hardening.md): what the readers check.
- [Licence and credit](../licence.md): what the licence allows.
