Skip to content

Commit eeaff40

Browse files
update
Session owner promotion to prepare for the potential of providing user-determined session owner promotion.
1 parent ef2fbe8 commit eeaff40

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ internal void SetSessionOwner(ulong sessionOwner)
239239
OnSessionOwnerPromoted?.Invoke(sessionOwner);
240240
}
241241

242+
#if ENABLE_SESSIONOWNER_PROMOTION_NOTIFICATION
243+
public void PromoteSessionOwner(ulong clientId)
244+
#else
242245
internal void PromoteSessionOwner(ulong clientId)
246+
#endif
243247
{
244248
if (!DistributedAuthorityMode)
245249
{
@@ -256,10 +260,18 @@ internal void PromoteSessionOwner(ulong clientId)
256260
{
257261
SessionOwner = clientId,
258262
};
259-
var clients = ConnectionManager.ConnectedClientIds.Where(c => c != LocalClientId).ToArray();
260-
foreach (var targetClient in clients)
263+
264+
if (CMBServiceConnection)
265+
{
266+
ConnectionManager.SendMessage(ref sessionOwnerMessage, NetworkDelivery.ReliableSequenced, ServerClientId);
267+
}
268+
else
261269
{
262-
ConnectionManager.SendMessage(ref sessionOwnerMessage, NetworkDelivery.ReliableSequenced, targetClient);
270+
var clients = ConnectionManager.ConnectedClientIds.Where(c => c != LocalClientId).ToArray();
271+
foreach (var targetClient in clients)
272+
{
273+
ConnectionManager.SendMessage(ref sessionOwnerMessage, NetworkDelivery.ReliableSequenced, targetClient);
274+
}
263275
}
264276
}
265277

0 commit comments

Comments
 (0)