# Listening to Events

When a class needs to receive network events, such as be notified of data arrival, it must implement the `NetworkEventListener` interface. Once registered in the `NetworkManager`, it will receive network events each time the server generates them.

## NetworkEventListener

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

* `onDataArrived()`: called when the server sends player data.

## MockNetworkEventListener

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

* `getDataArrived()`: returns the amount of network events received.
* `resetDataArrived()`: resets the counter of network events received.
* `getStoredPlayers()`: returns the player data received in the most recent network event.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://asrob-uc3m.gitbook.io/robotdevastation-developer-manual/robotdevastation/managers/network-management/listening-to-events.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
