cordova-plugin-opentok
cordova-plugin-opentok copied to clipboard
#112 Added check to ensure we don't unsubscribe when disconnected
Contributing checklist
- [x] Code must follow existing styling conventions
- [x] Added a descriptive commit message
Solves issue(s)
#112
Explanation
When disconnecting from session, there are still events being emitted, and depending on which one comes first, it will try to unsubscribe a subscriber while the Session doesn't know the subscriber. And that causes crashes.
I added a simple check to prevent that, it is a different boolean then the sessionConnected
boolean because that one gets sets within those events, so it wouldnt have much influences. This way it does not break any of the current code. (also added a subscriberCollection.remove
because otherwise it will try to remove subscriber that doesnt exist anymore)
@wolfenrain I'm happy to store a disconnected state, but we should use the events such as onConnected
, onDisconnected
, etc to know the state of the session. WDYT?