examples: webrtc: js: Fix for offer send onNegotiationNeeded
Client was sending offer onNegotiationNeeded and onNegotiationNeeded was called when datachannel was created or when localstream is added to RTCPeerConnection.
Consider the flow where
- Rust App sends offer to JS App.
- JS App recieves the offer sets remote description and sends answer
- But setRemoteDescription calls onNegotitationNeeded and then sends an offer in parallell withe the answer
- Rust App recieves the offer and errors out with processing since offer was sent by the rust app and answer is recieved but offer came again
The state management had a lot more issues with respect to 2 JS Apps communicating as well for OFFER_REQUEST flows etc. This commit refactors the entire js client to ensure it works reliably with Both 2 JS Apps as well as a Rust and Js App.