Invoking joinRoom():

If self* is already in the Room, proceed to step 1, else step 6.

Exit from current room :
1. Invoke leaveRoom() to disconnect self from the current Room.
2. This stops any attached Stream if provided constraints for both audio and video is false.

3. Then, mediaAccessStopped is triggered if there was any Stream that was terminated.

4. Event peerLeft would trigger for the previous Room self was connected to. 
5. After Event peerLeft has been triggered, the leaveRoom() callback success will be triggered.

Join room:
6. Invoke init() to retrieve connection information for the selected Room to join to.
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.
7. Event readyStateChange is triggered with state INIT, when the data has been parsed in the provided configuration data.

8. Event readyStateChange is triggered with state LOADINGas it retrieves the data from the platform server.

9. Event readyStateChange is triggered with state COMPLETEDonce the SDK has parsed and retrieved the data from the platform server.

10. 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.