> For the complete documentation index, see [llms.txt](https://asrob-uc3m.gitbook.io/robotdevastation-developer-manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://asrob-uc3m.gitbook.io/robotdevastation-developer-manual/robotdevastation/managers/camera-management/listening-to-events.md).

# Listening to Events

When a class needs to receive image events, such as be notified of the arrival of a new image frame, it must implement the `ImageEventListener` interface. Once registered in the `ImageManager`, it will receive network events each time a new image is received.

## ImageEventListener

This interface has the following function, that is called when the corresponding event is triggered in the `ImageManager`:

* `onImageArrived()`: called when a new image has arrived. The argument passed is not the new image, but the `ImageManager`that triggered the event. This way, the received image can be protected from being corrupted, as it cannot be overwritten while it is being read.

## MockImageEventListener

Implements the following functions to extract information about received network events:

* `getDataArrived()`: returns the amount of image events received.
* `resetDataArrived()`: resets the counter of image events received.
* `getStoredImage()`: returns the image received in the most recent image event.
