> For the complete documentation index, see [llms.txt](https://dotsnet.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dotsnet.gitbook.io/docs/user-manual/networkclientsystem.md).

# NetworkClientSystem

`NetworkClientSystem` is the main client class, found in `ClientWorld`.

`NetworkClientSystemAuthoring` can be used to interact with it from the Inspector. In the example scene, the NetworkClient scene object has the authoring component:

![](https://lh3.googleusercontent.com/UVq_h2UBvmiUf5EC4c2HwsTf83ocUVGelH10vq0dtpqY9bWGxJ6RtcYGlcWwV2SvhxGUBuBl7tnG-q34Ku7labFY3qD3CYWpMs6u95ySOxovK-ReS-Z6HXfUX4QFzAPlIU3of-4V)

## NetworkClientSystem API

| Property:                  | Description:                                                                                                                                                                                                                                                                                                                                                              |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `state`                    | Current client state (disconnected/connecting/connected).                                                                                                                                                                                                                                                                                                                 |
| `disconnectedFreezesScene` | <p>Convenience feature that decides what to do after the client disconnects. By default, all NetworkEntities will be destroyed and cleaned up immediately.</p><p>Enable this flag to freeze them in the scene instead, which is what some MMOs do because it looks cool.</p><p>The NetworkEntities will automatically be cleaned up in the next Connect() call again.</p> |
| `spawned`                  | All spawned Entities by netId that are around the player. Unlike the server, those aren’t all entities that were spawned in the world. Only the player’s observers.                                                                                                                                                                                                       |

| Function:                     | Description:                                                                                                                                                                                                                                                                                                                                           |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `Connect(address)`            | Connect to a server listening on the specified address. This is not blocking, it will simply start the connect process, set the state to CONNECTING and then to CONNECTED a bit later.                                                                                                                                                                 |
| `Disconnect()`                | Disconnect from the server. This happens immediately and the state is set to DISCONNECTED.                                                                                                                                                                                                                                                             |
| `Send(message, channel)`      | <p>Send a NetworkMessage to the server.</p><p>Some transports support different channels.</p><p>If in doubt, leave the channel at default = Reliable.</p>                                                                                                                                                                                              |
| `OnConnected()`               | Virtual function for classes that inherit from NetworkClientSystem.                                                                                                                                                                                                                                                                                    |
| `OnDisconnected()`            | Virtual function for classes that inherit from NetworkClientSystem.                                                                                                                                                                                                                                                                                    |
| `RegisterHandler<T>(handler)` | <p>Register a handler for an incoming message. Inheriting from NetworkClientMessageSystem registers it automatically.</p><p></p><p><strong>NOTE</strong>: custom allocator for the new NetworkMessage\<T> can be passed as third parameter in case a system wants to reuse large messages like WorldStateMessage instead of allocating each time. </p> |
| `UnregisterHandler<T>`        | Unregister handler for the NetworkMessage type.                                                                                                                                                                                                                                                                                                        |
