> For the complete documentation index, see [llms.txt](https://netick.gitbook.io/v1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://netick.gitbook.io/v1/listening-to-network-events.md).

# Listening to Network Events

Netick has several useful callbacks you can use:

| Callbacks                                                                  | Description                                                                                                                | Invoke target |
| -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | ------------- |
| OnStartup(NetworkSandbox sandbox)                                          | Called when Netick has been started.                                                                                       | Client/Server |
| OnShutdown(NetworkSandbox sandbox)                                         | Called when Netick has been shut down.                                                                                     | Client/Server |
| OnInput(NetworkSandbox sandbox)                                            | Called to read inputs.                                                                                                     | Client/Server |
| OnConnectRequest(NetworkSandbox sandbox, NetworkConnectionRequest request) | Called on the server when a client tries to connect. Use request to decide whether or not to allow this client to connect. | Server        |
| OnConnectFailed(NetworkSandbox sandbox, ConnectionFailedReason reason)     | Called on the client when the connection to the server was refused, or simply failed.                                      | Client        |
| OnConnectedToServer(NetworkSandbox sandbox, NetworkConnection server)      | Called on the client when the connection to the server has succeeded.                                                      | Client        |
| OnClientConnected(NetworkSandbox sandbox, NetworkConnection client)        | Called on the server when a specific client has connected.                                                                 | Server        |
| OnClientDisconnected(NetworkSandbox sandbox, NetworkConnection client)     | Called on the server when a specific client has disconnected.                                                              | Server        |
| OnSceneLoaded(NetworkSandbox sandbox)                                      | Called on both the client and the server when the scene has been loaded.                                                   | Client/Server |
| OnSceneLoadStarted(NetworkSandbox sandbox)                                 | Called on both the client and the server before beginning to load the new scene.                                           | Client/Server |
| OnClientSceneLoaded(NetworkSandbox sandbox, NetworkConnection client)      | Called on the server when a specific client finished loading the scene.                                                    | Server        |
| OnObjectCreated(NetworkObject obj)                                         | Called when a network object has been created/initialized.                                                                 | Client/Server |
| OnObjectDestroyed(NetworkObject obj)                                       | Called when a network object has been destroyed/recycled.                                                                  | Client/Server |

You can override these methods on a class inheriting from NetworkEventsListner, and add it to an object in the scene, and Netick will find it automatically. Or, you can add it to a network prefab that you instantiate, and Netick will also find it can call methods on it.

You could also add the component NetworkEvents to an object, which does the same, but the difference is that you can plug your events right into it.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://netick.gitbook.io/v1/listening-to-network-events.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
