title: WebRTC double video-offer message
body: <p>I'm trying to build a video-chat with a WebRTC. The problem which I have, is that the video-offer is going in both sides like:</p>
  
  <pre><code>PC1 -&gt; send video-offer
  PC2 &lt;- handle video-offer message
  PC2 -&gt; send video-answer
  PC1 &lt;- handle video-answer (when there is debugger breakpoint, the connection is working)
  PC2 -&gt; send video-offer
  ...
  </code></pre>
  
  <p>I'm sending video-offer message only in negotiationEventHandler:</p>
  
  <pre><code>function handleNegotiationNeededEvent() {
      logMessage('HandleNegotiationNeededEvent fired!');
      myPeerConnection.createOffer() //tworzymy SDP offer dla drugiego uzytkownika
          .then(function (offer) {
          return myPeerConnection.setLocalDescription(offer);
      })
          .then(function () {
              sendToWebSocket(msgTypeVideoOffer, senderId, receiverId, JSON.stringify(myPeerConnection.localDescription));
          })
          .catch(reportError);
  }
  </code></pre>
  
  <p>and handling video-offer / video-answer in two functions</p>
  
  <pre><code>function handleVideoOfferMsg(msg){
      logMessage("handle video-offer message call");
      var localStream = null;
  
      createPeerConnection();
  
      var desc = new RTCSessionDescription(JSON.parse(msg.messageContent));
      debugger;
      myPeerConnection.setRemoteDescription(desc)
          .then(function () {
              return navigator.mediaDevices.getUserMedia(mediaConstraints);
          })
          .then(function (stream) {
              localStream = stream;
              document.getElementById("local_video").srcObject = localStream;
              myPeerConnection.addStream(localStream);
          })
          .then(function () { //Utworz odpowiedz
              return myPeerConnection.createAnswer();
          })
          .then(function (answer) { //Ustaw ja sobie jako lokalna
              return myPeerConnection.setLocalDescription(answer);
          })
          .then(function () { //I wyslij SDP do peera
              sendToWebSocket(msgTypeVideoAnswer, senderId, receiverId, JSON.stringify(myPeerConnection.localDescription));
          })
          .catch(handleGetUserMediaError);
  }
  
  function handleVideoAnswerMessage(message) {
      logMessage("handle video answer message" + message);
      var desc = message.messageContent;
      myPeerConnection.setRemoteDescription(JSON.parse(desc));
  }
  </code></pre>
  
  <p>The problem is, that handling video-offer is setting a new objects, what probably is a reason of losing a connection.</p>