restcomm-android-sdk
restcomm-android-sdk copied to clipboard
Improve handling of disconnection within RCConnection
Right now it's messy & very easy to break because we have 2 methods that handle most of it:
- handleDisconnected(), called when:
- Signaling event that 200 OK to our outgoing BYE is received
- Signaling event that BYE was received from peer
- Signaling event that incoming call got cancelled
- handleDisconnect(), called when:
- We call RCConnection.disconnect()
- Media event onIceServersError is received
- Media event onIceDisconnected is received
- Media event onPeerConnectionError is received
- Permission(s) are denied by the user
- We call RCConnection.disconnect()
- The system failed to open camera
Moreover calls to listener.onDisconnected() are scattered all around the code. We need to consolidate all those inside the single method handing disconnection, together with any other code pertaining to disconnection processing.
When merging all that functionality we need to take into account the following:
- When user asks to disconnect we could avoid sending BUT we need a snappy experience; if there's an issue with signaling facilities we cannot afford to wait 32 seconds that signaling facilities take to time out.
- ...