# C API: Events

A `sona_event` holds `type`, `avatar`, `code`, `message` and `fix`. `message` and `fix` are valid until the next `sona_poll_event`.

| Type | Meaning |
|---|---|
| `SONA_EVENT_NONE` | Nothing |
| `SONA_EVENT_READY` | An avatar is built and drawable (`avatar` is set) |
| `SONA_EVENT_FAILED` | An avatar could not be built; `code` says why (`avatar` is set) |
| `SONA_EVENT_ERROR` | Context-wide: licence, app, platform, build, limit, gate or context |
| `SONA_EVENT_LICENCE_OK` | The native check passed |

## sona_poll_event

```c
int sona_poll_event(sona_ctx *ctx, sona_event *out);
```

| Parameter | Type | Meaning | Default |
|---|---|---|---|
| `ctx` | `sona_ctx *` | The context | required |
| `out` | `sona_event *` | Receives the [`sona_event`](../fields.md#sona_event) | required |

**Returns** `int`.

**Example**:

```c
sona_event x_event;
memset(&x_event, 0, sizeof x_event);
int x_got = sona_poll_event(ctx, &x_event);
printf("sona_poll_event: %lld\n", (long long)x_got);
```

1 when an event was written to `*out`, 0 when there are none. Call it in a loop after `sona_update`.
