---
title: Lifecycle methods
source: https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/lifecycle/overview
---

## Lifecycle methods

| Method                                                                                                                          | Description                                                                 |
| ------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [nrAppStarted](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/lifecycle/nrappstarted)         | Send an APP_STARTED event of type ConnectedDeviceSystem.                    |
| [nrSceneLoaded](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/lifecycle/nrsceneloaded)       | Send a SCENE_LOADED event of type ConnectedDeviceSystem.                    |
| [nrProcessMessage](https://docs.newrelic.com/docs/streaming-video-&-ads/installation/roku/agent-api/lifecycle/nrprocessmessage) | Check for a system log message, process it and sends the appropriate event. |

## Examples

### Send APP_STARTED event

```brightscript
sub Main(aa as Object)
    ...
    nrAppStarted(m.nr, aa)
```

### Send SCENE_LOADED event

```brightscript
nrSceneLoaded(m.nr, "MyVideoScene")
```

### Process system log messages

```brightscript
while (true)
    msg = wait(0, m.port)
    if nrProcessMessage(m.nr, msg) = false
        if type(msg) = "roPosterScreenEvent"
            if msg.isScreenClosed()
                exit while
            end if
        end if
    end if
end while
```
