Skip to content

Fix reconnecting issues#8

Open
gertdrui wants to merge 7 commits into
chinloyal:masterfrom
gertdrui:fix-reconnecting
Open

Fix reconnecting issues#8
gertdrui wants to merge 7 commits into
chinloyal:masterfrom
gertdrui:fix-reconnecting

Conversation

@gertdrui
Copy link
Copy Markdown

Currently on Android when doing:

pusher.connect()
pusher.disconnect()
pusher.connect()

we no longer receive onConnectionStateChange updates

This change will add or replace a streamsubscription on each connect(), which fixes the issue.
Also, each call to connect added another ConnectionListener instance which duplicated calls being sent to flutter, which should now be fixed.

/// Add a listener to the event channel stream for pusher,
/// any class that extends [StreamHandler] should use this method.
void registerListener(String classId, dynamic Function(dynamic) method) {
_eventStreamSubscription?.cancel();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

With this line are you able to receive connection state change events after binding to an event? Because whenever you bind it calls registerListener so wouldn't this line cancel the stream causing all classes using the event channel to not receive any events?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, connection state changes still work after binding because Channel and PusherClient extend this abstract class on their own. bind() and connect() only re-subscribes their own instance.

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