Skip to content

fix for realtime multiple subscription 15x - #801

Merged
lohanidamodar merged 9 commits into
masterfrom
fix-flutter-realtime-multisub-15x
Apr 24, 2024
Merged

lohanidamodar merged 9 commits into
masterfrom
fix-flutter-realtime-multisub-15x

Conversation

@lohanidamodar

@lohanidamodar lohanidamodar commented Mar 14, 2024 •

Copy link
Copy Markdown
Member

What does this PR do?

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

@stnguyen90

Copy link
Copy Markdown
Contributor

Sorry, I'll try to get to this on Monday.

@stnguyen90 stnguyen90 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still getting 2 events:

image

@stnguyen90

Copy link
Copy Markdown
Contributor

@lohanidamodar, I think the problem is if you subscribe multiple times in a loop like:

    try {
      final document = await widget.database.listDocuments(
        databaseId: ID.custom(databaseId),
        collectionId: ID.custom(collectionId), //change your collection id
      );
      for (var doc in document.documents) {
        _subscribe(
            ['databases.default.collections.usernames.documents.${doc.$id}']);
      }
    } on AppwriteException catch (e) {
      print(e.message);
    }

This can be called multiple times, creating multiple websockets. In this case 5:

image

Comment thread templates/flutter/lib/src/realtime_mixin.dart.twig

@abnegate abnegate left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a few places we need to revert back from Appwrite to a template substitution

@lohanidamodar

Copy link
Copy Markdown
Member Author

There's a few places we need to revert back from Appwrite to a template substitution

Updated

@lohanidamodar

Copy link
Copy Markdown
Member Author

@stnguyen90 updated

@stnguyen90
stnguyen90 self-requested a review April 15, 2024 18:28
Comment thread templates/flutter/lib/src/realtime_mixin.dart.twig
do not close subscription if creating socket is true to prevent concurrent modification error
Comment thread templates/flutter/lib/src/realtime_mixin.dart.twig
@lohanidamodar
lohanidamodar merged commit 59234d6 into master Apr 24, 2024
@lohanidamodar
lohanidamodar deleted the fix-flutter-realtime-multisub-15x branch April 24, 2024 02:47
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.

3 participants