You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/basics/connection-approval.md
+20-20
Original file line number
Diff line number
Diff line change
@@ -7,26 +7,6 @@ With every new connection, Netcode for GameObjects performs a handshake in addit
7
7
8
8
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.
9
9
10
-
## `NetworkManager.ConnectionApprovalRequest`
11
-
12
-
This class represents the client-to-server request which has:
13
-
14
-
-**ClientNetworkId**: the connecting client identifier
15
-
-**Payload**: any additional user-defined connection data
16
-
17
-
## `NetworkManager.ConnectionApprovalResponse`
18
-
19
-
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:
20
-
21
-
-**Approved**: When `true`, the player is approved. When `false`, the player is denied.
22
-
-**CreatePlayerObject**: When `true`, the server spawns a player Prefab for the connecting client. When `false`, the connecting client will have no player Prefab spawned.
23
-
-**PlayerPrefabHash**: The type of player Prefab to use for the authorized player (if this is `null`, it uses the default NetworkManager-defined player Prefab)
24
-
-**Position** and **Rotation**: The position and rotation of the player when spawned.
25
-
-**Pending**: Provides the ability to mark the approval as pending to delay the authorization until other user-specific code finishes the approval process.
26
-
-**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.
27
-
28
-
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.
29
-
30
10
## Server-side connection approval example
31
11
32
12
```csharp
@@ -69,6 +49,26 @@ private void ApprovalCheck(NetworkManager.ConnectionApprovalRequest request, Net
69
49
}
70
50
```
71
51
52
+
## `NetworkManager.ConnectionApprovalRequest`
53
+
54
+
This class represents the client-to-server request which has:
55
+
56
+
-**ClientNetworkId**: the connecting client identifier
57
+
-**Payload**: any additional user-defined connection data
58
+
59
+
## `NetworkManager.ConnectionApprovalResponse`
60
+
61
+
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:
62
+
63
+
-**Approved**: When `true`, the player is approved. When `false`, the player is denied.
64
+
-**CreatePlayerObject**: When `true`, the server spawns a player Prefab for the connecting client. When `false`, the connecting client will have no player Prefab spawned.
65
+
-**PlayerPrefabHash**: The type of player Prefab to use for the authorized player (if this is `null`, it uses the default NetworkManager-defined player Prefab)
66
+
-**Position** and **Rotation**: The position and rotation of the player when spawned.
67
+
-**Pending**: Provides the ability to mark the approval as pending to delay the authorization until other user-specific code finishes the approval process.
68
+
-**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.
69
+
70
+
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.
71
+
72
72
## Sending an approval declined reason (`NetworkManager.ConnectionApprovalResponse.Reason`)
73
73
74
74
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.
0 commit comments