11using Cysharp . Threading . Tasks ;
22using DCL . Diagnostics ;
3- using DCL . Multiplayer . Connections . Audio ;
3+ using DCL . FeatureFlags ;
44using DCL . Multiplayer . Connections . Credentials ;
55using DCL . WebRequests ;
66using LiveKit . Internal ;
@@ -53,17 +53,14 @@ public abstract class ConnectiveRoom : IConnectiveRoom
5353 {
5454 private static readonly TimeSpan HEARTBEATS_INTERVAL = TimeSpan . FromSeconds ( 1 ) ;
5555 private static readonly TimeSpan CONNECTION_LOOP_RECOVER_INTERVAL = TimeSpan . FromSeconds ( 5 ) ;
56- private readonly string logPrefix ;
5756
57+ private readonly string logPrefix ;
5858 private readonly InteriorRoom room = new ( ) ;
59-
6059 private readonly Atomic < IConnectiveRoom . ConnectionLoopHealth > connectionLoopHealth = new ( IConnectiveRoom . ConnectionLoopHealth . Stopped ) ;
61-
6260 private readonly Atomic < AttemptToConnectState > attemptToConnectState = new ( AttemptToConnectState . NONE ) ;
63-
6461 private readonly Atomic < IConnectiveRoom . State > roomState = new ( IConnectiveRoom . State . Stopped ) ;
65-
6662 private readonly IObjectPool < IRoom > roomPool ;
63+ private readonly bool isDuplicateIdentityStopFeatureEnabled ;
6764
6865 private CancellationTokenSource ? cancellationTokenSource ;
6966 private bool isDuplicateIdentityDetected ;
@@ -72,6 +69,8 @@ public abstract class ConnectiveRoom : IConnectiveRoom
7269
7370 protected ConnectiveRoom ( )
7471 {
72+ isDuplicateIdentityStopFeatureEnabled = FeaturesRegistry . Instance . IsEnabled ( FeatureId . STOP_ON_DUPLICATE_IDENTITY ) ;
73+
7574 logPrefix = GetType ( ) . Name ;
7675
7776 roomPool = new ObjectPool < IRoom > ( ( ) =>
@@ -166,9 +165,10 @@ private async UniTaskVoid RunAsync(CancellationToken token)
166165 await UniTask . Delay ( HEARTBEATS_INTERVAL , cancellationToken : token ) ;
167166 }
168167
169- if ( isDuplicateIdentityDetected )
168+
169+ if ( isDuplicateIdentityDetected && isDuplicateIdentityStopFeatureEnabled )
170170 {
171- ReportHub . Log ( ReportCategory . LIVEKIT , $ "{ logPrefix } - DuplicateIdentity detected, stopping reconnection loop") ;
171+ ReportHub . LogWarning ( ReportCategory . LIVEKIT , $ "{ logPrefix } - DuplicateIdentity detected, stopping reconnection loop") ;
172172 connectionLoopHealth . Set ( IConnectiveRoom . ConnectionLoopHealth . Stopped ) ;
173173 attemptToConnectState . Set ( AttemptToConnectState . NO_CONNECTION_REQUIRED ) ;
174174 }
@@ -294,13 +294,13 @@ protected async UniTask<RoomSelection> TryConnectToRoomAsync(string connectionSt
294294 return ( connectResult , roomSelection ) ;
295295 }
296296
297- private void OnConnectionUpdated ( IRoom room , ConnectionUpdate connectionUpdate , DisconnectReason ? disconnectReason = null )
297+ private void OnConnectionUpdated ( IRoom _ , ConnectionUpdate connectionUpdate , DisconnectReason ? disconnectReason )
298298 {
299- if ( connectionUpdate == ConnectionUpdate . Disconnected && disconnectReason == DisconnectReason . DuplicateIdentity )
299+ if ( connectionUpdate == ConnectionUpdate . Disconnected && disconnectReason is DisconnectReason . DuplicateIdentity && isDuplicateIdentityStopFeatureEnabled )
300300 {
301301 isDuplicateIdentityDetected = true ;
302302 cancellationTokenSource ? . SafeCancelAndDispose ( ) ;
303- ReportHub . Log ( ReportCategory . LIVEKIT , $ "{ logPrefix } - DuplicateIdentity disconnect reason received, interrupting reconnection attempts") ;
303+ ReportHub . LogWarning ( ReportCategory . LIVEKIT , $ "{ logPrefix } - DuplicateIdentity disconnect reason received, interrupting reconnection attempts") ;
304304 }
305305 }
306306 }
0 commit comments