Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarified protected connection call #61

Merged
merged 4 commits into from
May 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions docs/getting-started/unity3d-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,24 @@ The built-in demonstration comes with a single [room handler](https://github.com
public class ExampleManager : ColyseusManager<ExampleManager>
```
- Make an in-scene manager object to host your custom Manager script.
- Provide your Manager with a reference to your Colyseus Settings object in the scene inspector.

## Connecting to Your Colyseus Server:

- In order to connect to your server you first need to provide your Manager a reference to your Colyseus Settings object in the scene inspector.
- Call `ConnectToServer()` of your Manager to initiate a server connection:
## Client:

- Call the `InitializeClient()` method of your Manager to create a `ColyseusClient` object which is stored in the `client` variable of `ColyseusManager`. This will be used to create/join rooms and form a connection with the server.
```csharp
ExampleManager.Instance.ConnectToServer();
ExampleManager.Instance.InitializeClient();
```
- If your Manager has additional classes that need reference to your `Client`, you can override `InitializeClient` and make those connections in there.
```csharp
//In ExampleManager.cs
public override void InitializeClient()
{
base.InitializeClient();
//Pass the newly created Client reference to our RoomController
_roomController.SetClient(client);
}
```

## Client:

- When you connect to the server an instance of `ColyseusClient` is created and is stored in the `client` variable of `ColyseusManager`.
- You can get available rooms on the server by calling `GetAvailableRooms` of `ColyseusClient`:
```csharp
return await GetAvailableRooms<ColyseusRoomAvailable>(roomName, headers);
Expand Down Expand Up @@ -170,6 +175,7 @@ room.Send("createEntity", new EntityCreationMessage() { creationId = creationId,
```

### Room State:
> See how to generate your `RoomState` from [State Handling](https://docs.colyseus.io/state/schema/#client-side-schema-generation)
- Each room holds its own state. The mutations of the state are synchronized automatically to all connected clients.
- In regards to room state synchronization:
- When the user successfully joins the room, they receive the full state from the server.
Expand Down