Skip to content

Commit

Permalink
Develop into main to publish NGO 1.10.0 and tools 2.2.0 (#1312)
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbacakes committed Jul 29, 2024
2 parents 950baec + e9d17e9 commit 2bf18a7
Show file tree
Hide file tree
Showing 136 changed files with 17,032 additions and 123 deletions.
2 changes: 1 addition & 1 deletion docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ For more information, check out [Release Notes](release-notes/ngo-changelog.md)

Netcode for GameObjects supports the following versions:

- Unity 2021.3 and later
- Unity 6.0+ and later
- Mono and IL2CPP [Scripting Backends](https://docs.unity3d.com/Manual/scripting-backends.html)

Netcode for GameObjects supports the following platforms:
Expand Down
40 changes: 20 additions & 20 deletions docs/basics/connection-approval.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,6 @@ With every new connection, Netcode for GameObjects performs a handshake in addit

When you set the ConnectionApproval property of the NetworkManager to true, Netcode for GameObjects checks to make sure the `NetworkManager.ConnectionApprovalCallback` has been assigned. If assigned, the connection approval process is used for connecting clients to decide whether to allow a connection or deny it. If you don't assign the `NetworkManager.ConnectionApprovalCallback` (even with the `NetworkManager.ConnectionApprovalCallback` set to `true`), Netcode for GameObjects uses basic authentication for the user, which automatically authorizes and assigns the default player Prefab.

## `NetworkManager.ConnectionApprovalRequest`

This class represents the client-to-server request which has:

- **ClientNetworkId**: the connecting client identifier
- **Payload**: any additional user-defined connection data

## `NetworkManager.ConnectionApprovalResponse`

This is how the connection approval response is formed by server-side specific user code in the handler assigned to `NetworkManager.ConnectionApprovalCallback`. On the server side, this class has all the connection approval response information required to either allow or reject a player attempting to connect. It also has the following properties:

- **Approved**: When `true`, the player is approved. When `false`, the player is denied.
- **CreatePlayerObject**: When `true`, the server spawns a player Prefab for the connecting client. When `false`, the connecting client will have no player Prefab spawned.
- **PlayerPrefabHash**: The type of player Prefab to use for the authorized player (if this is `null`, it uses the default NetworkManager-defined player Prefab)
- **Position** and **Rotation**: The position and rotation of the player when spawned.
- **Pending**: Provides the ability to mark the approval as pending to delay the authorization until other user-specific code finishes the approval process.
- **Reason**: If `Approved` is `false`, you can populate this with a string-based message (or JSON) to send the reason the client wasn't approved.

In earlier versions of Netcode for GameObjects, you had to provide a callback to invoke within the connection approval handler method. It's now only necessary to set the appropriate properties of the `NetworkManager.ConnectionApprovalResponse` class. Part of this update allows you to set your `ConnectionApprovalResponse` to `Pending`, providing extra time to process any other tasks involved with the player approval process.

## Server-side connection approval example

```csharp
Expand Down Expand Up @@ -69,6 +49,26 @@ private void ApprovalCheck(NetworkManager.ConnectionApprovalRequest request, Net
}
```

## `NetworkManager.ConnectionApprovalRequest`

This class represents the client-to-server request which has:

- **ClientNetworkId**: the connecting client identifier
- **Payload**: any additional user-defined connection data

## `NetworkManager.ConnectionApprovalResponse`

This is how the connection approval response is formed by server-side specific user code in the handler assigned to `NetworkManager.ConnectionApprovalCallback`. On the server side, this class has all the connection approval response information required to either allow or reject a player attempting to connect. It also has the following properties:

- **Approved**: When `true`, the player is approved. When `false`, the player is denied.
- **CreatePlayerObject**: When `true`, the server spawns a player Prefab for the connecting client. When `false`, the connecting client will have no player Prefab spawned.
- **PlayerPrefabHash**: The type of player Prefab to use for the authorized player (if this is `null`, it uses the default NetworkManager-defined player Prefab)
- **Position** and **Rotation**: The position and rotation of the player when spawned.
- **Pending**: Provides the ability to mark the approval as pending to delay the authorization until other user-specific code finishes the approval process.
- **Reason**: If `Approved` is `false`, you can populate this with a string-based message (or JSON) to send the reason the client wasn't approved.

In earlier versions of Netcode for GameObjects, you had to provide a callback to invoke within the connection approval handler method. It's now only necessary to set the appropriate properties of the `NetworkManager.ConnectionApprovalResponse` class. Part of this update allows you to set your `ConnectionApprovalResponse` to `Pending`, providing extra time to process any other tasks involved with the player approval process.

## Sending an approval declined reason (`NetworkManager.ConnectionApprovalResponse.Reason`)

If you need to deny a player from connecting for any reason (such as if they reached the maximum number of connections or provided an invalid authorization), the `NetworkManager.ConnectionApprovalResponse` structure provides you with the optional `NetworkManager.ConnectionApprovalResponse.Reason` property.
Expand Down
Loading

0 comments on commit 2bf18a7

Please sign in to comment.