diff --git a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs index cff2768405..d869826d14 100644 --- a/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs +++ b/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs @@ -239,7 +239,11 @@ internal void SetSessionOwner(ulong sessionOwner) OnSessionOwnerPromoted?.Invoke(sessionOwner); } +#if ENABLE_SESSIONOWNER_PROMOTION_NOTIFICATION + public void PromoteSessionOwner(ulong clientId) +#else internal void PromoteSessionOwner(ulong clientId) +#endif { if (!DistributedAuthorityMode) { @@ -256,10 +260,18 @@ internal void PromoteSessionOwner(ulong clientId) { SessionOwner = clientId, }; - var clients = ConnectionManager.ConnectedClientIds.Where(c => c != LocalClientId).ToArray(); - foreach (var targetClient in clients) + + if (CMBServiceConnection) + { + ConnectionManager.SendMessage(ref sessionOwnerMessage, NetworkDelivery.ReliableSequenced, ServerClientId); + } + else { - ConnectionManager.SendMessage(ref sessionOwnerMessage, NetworkDelivery.ReliableSequenced, targetClient); + var clients = ConnectionManager.ConnectedClientIds.Where(c => c != LocalClientId).ToArray(); + foreach (var targetClient in clients) + { + ConnectionManager.SendMessage(ref sessionOwnerMessage, NetworkDelivery.ReliableSequenced, targetClient); + } } } diff --git a/com.unity.netcode.gameobjects/Runtime/Messaging/Messages/ConnectionApprovedMessage.cs b/com.unity.netcode.gameobjects/Runtime/Messaging/Messages/ConnectionApprovedMessage.cs index a89478be0a..176a35fdf8 100644 --- a/com.unity.netcode.gameobjects/Runtime/Messaging/Messages/ConnectionApprovedMessage.cs +++ b/com.unity.netcode.gameobjects/Runtime/Messaging/Messages/ConnectionApprovedMessage.cs @@ -366,21 +366,18 @@ public void Handle(ref NetworkContext context) if (!networkManager.SceneManager.IsRestoringSession) { - // Synchronize the service with the initial session owner's loaded scenes and spawned objects - networkManager.SceneManager.SynchronizeNetworkObjects(NetworkManager.ServerClientId, true); - // Spawn any in-scene placed NetworkObjects networkManager.SpawnManager.ServerSpawnSceneObjectsOnStartSweep(); + // Synchronize the service with the initial session owner's loaded scenes and spawned objects + networkManager.SceneManager.SynchronizeNetworkObjects(NetworkManager.ServerClientId, true); + // Spawn the local player of the session owner if (networkManager.AutoSpawnPlayerPrefabClientSide) { networkManager.ConnectionManager.CreateAndSpawnPlayer(OwnerClientId); } - // Synchronize the service with the initial session owner's loaded scenes and spawned objects - networkManager.SceneManager.SynchronizeNetworkObjects(NetworkManager.ServerClientId, true); - // With scene management enabled and since the session owner doesn't send a scene event synchronize to itself, // we need to notify the session owner that everything should be synchronized/spawned at this time. networkManager.SpawnManager.NotifyNetworkObjectsSynchronized();