Exit from current room :
1. Invoke leaveRoom() to disconnect self from the current Room.
3. Then, mediaAccessStopped is triggered if there was any Stream that was terminated.
6a. Event readyStateChange would be triggered with the state ERROR, when it fails to retrieve the data from the platform server or when some dependencies aren't loaded. This may happen in between the stages of INIT and COMPLETED state.
6b. joinRoom() callback error will then be triggered.
8. Event readyStateChange is triggered with state LOADING, as it retrieves the data from the platform server.
9. Event readyStateChange is triggered with state COMPLETED, once the SDK has parsed and retrieved the data from the platform server.
10. socket.io client connection with platform signalling is now started.
11. Event channelOpen is triggered for the current Room. At this stage, self is not yet connected except the socket connection is opened.
If Stream constraints are passed in joinRoom(), proceed to step 12, else step 15.
12. Any existing attached stream is stopped and replaced with the new stream.
If Stream constraints audio and video is not false, proceed to step 13, else step 15.
13. Invoke getUserMedia() to retrieve Stream.
14. After Stream is successfully retrieved, Event mediaAccessSuccess will be triggered and getUserMedia() callback success will be triggered.
14a. Event mediaAccessError is triggered, if attempt at retrieving Stream fails. If audioFallback is set to true in the init(), proceed to step 14b, else step 14e.
14b. Invokes getUserMedia() again to retrieve audio only Stream.14c. After audio only Stream successfully retrieved, Event mediaAccessSuccess is triggered and getUserMedia() callback success will be triggered. Skip to step 16.14d. Event mediaAccessError state would trigger for the failed attempt of retrieving audio only Stream.14e. getUserMedia() callback error will be triggered.14f. After getUserMedia() callback triggers an error, joinRoom() callback error will be triggered.
15. self joins the selected room.
16. Event peerJoined would be triggered for the current Room self was connected to.
17. After Event peerJoined has been triggered, both joinRoom() callback success and the incomingStream event will be triggered.
* Self is the local peer.