Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added reconnection logic to LiveKitController #420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shwetd19
Copy link

Description

This implements an automatic reconnection mechanism for LiveKit rooms to handle network disruptions gracefully. Currently, when users lose connection to a room, they need to manually rejoin. This implementation adds automatic reconnection attempts with proper user feedback and state management using GetX.

The changes include:

  • Automatic reconnection logic with configurable retry attempts
  • Connection state tracking using GetX observables
  • User feedback system for connection status
  • Proper cleanup of reconnection attempts
  • Enhanced error handling and logging

Fixes #419

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  1. Network Disruption Tests:

    • Simulated network disconnections using Chrome DevTools
    • Verified reconnection attempts (3 times with 2-second intervals)
    • Confirmed proper user notifications during reconnection process
  2. State Management Tests:

    • Verified connection state updates correctly
    • Tested cleanup on room exit
    • Confirmed reconnection counter resets after successful reconnection
  3. Integration Tests:

    • Tested with existing SingleRoomController
    • Verified compatibility with PairChatController
    • Confirmed no interference with existing room functionality

Test Configuration:

void main() {
  testWidgets('LiveKit reconnection test', (WidgetTester tester) async {
    final controller = LiveKitController(
      liveKitUri: 'wss://test.livekit.cloud',
      roomToken: 'test-token'
    );
    
    // Simulate disconnect
    await tester.pumpAndSettle();
    await controller.handleDisconnection();
    
    // Verify reconnection attempts
    expect(controller.reconnectAttempts, 1);
    expect(controller.isConnected.value, false);
    
    // Wait for reconnection
    await tester.pump(const Duration(seconds: 2));
    expect(controller.reconnectAttempts, 2);
  });
}

Screenshots:
[Add reconnection notification screenshots]

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@shwetd19
Copy link
Author

Hey @AyaNady17 @Aarush-Acharya can you please check this once, please let me know if any changes are required, Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding automatic reconnection mechanism to LiveKit implementation
1 participant