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

Fix reconnecting issues #8

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

gertdrui
Copy link

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.

@@ -12,6 +12,8 @@ abstract class StreamHandler {
/// 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
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
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.

None yet

3 participants