Skip to content

Commit 5958c9b

Browse files
committed
Removed AddHostData method
1 parent 4ce6534 commit 5958c9b

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

Assets/BossRoom/Scripts/Shared/Net/ConnectionManagement/ServerGameNetPortal.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Unity.Multiplayer.Samples.BossRoom.Client;
55
using UnityEngine;
66
using Unity.Netcode;
7+
using Unity.Services.Authentication;
78
using UnityEngine.SceneManagement;
89

910
namespace Unity.Multiplayer.Samples.BossRoom.Server
@@ -146,7 +147,7 @@ private void ApprovalCheck(byte[] connectionData, ulong clientId, NetworkManager
146147
// Approval check happens for Host too, but obviously we want it to be approved
147148
if (clientId == NetworkManager.Singleton.LocalClientId)
148149
{
149-
SessionManager<SessionPlayerData>.Instance.AddHostData(
150+
SessionManager<SessionPlayerData>.Instance.SetupConnectingPlayerSessionData(clientId, AuthenticationService.Instance.PlayerId,
150151
new SessionPlayerData(clientId, m_Portal.PlayerName, m_Portal.AvatarRegistry.GetRandomAvatar().Guid.ToNetworkGuid(), 0, true));
151152

152153
connectionApprovedCallback(true, null, true, null, null);

Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,6 @@ protected SessionManager()
6363
/// </summary>
6464
private Dictionary<ulong, string> m_ClientIDToPlayerId;
6565

66-
public void AddHostData(T sessionPlayerData)
67-
{
68-
if (sessionPlayerData.ClientID == m_NetworkManager.ServerClientId)
69-
{
70-
m_ClientData.Add(k_HostGUID, sessionPlayerData);
71-
m_ClientIDToPlayerId.Add(sessionPlayerData.ClientID, k_HostGUID);
72-
}
73-
else
74-
{
75-
Debug.LogError($"Invalid ClientId for host. Got {sessionPlayerData.ClientID}, but should have gotten {m_NetworkManager.ServerClientId}.");
76-
}
77-
}
78-
7966
/// <summary>
8067
/// Handles the case where NetworkManager has told us a client has disconnected. This includes ourselves, if we're the host,
8168
/// and the server is stopped."
@@ -120,7 +107,7 @@ private void Clear()
120107
/// Adds a connecting player's session data if it is a new connection, or updates their session data in case of a reconnection. If the connection is not valid, simply returns false.
121108
/// </summary>
122109
/// <param name="clientId">This is the clientId that Netcode assigned us on login. It does not persist across multiple logins from the same client. </param>
123-
/// <param name="playerId">This is the playerId that is unique to this client and persists accross multiple logins from the same client</param>
110+
/// <param name="playerId">This is the playerId that is unique to this client and persists across multiple logins from the same client</param>
124111
/// <param name="sessionPlayerData">The player's initial data</param>
125112
/// <returns>True if the player connection is valid (i.e. not a duplicate connection)</returns>
126113
public bool SetupConnectingPlayerSessionData(ulong clientId, string playerId, T sessionPlayerData)

0 commit comments

Comments
 (0)