title: about socket connection in webrtc using socket,io
body: <p>i am study about peer to peer video chat and i follow the google Codelab for study.and i am just read theoretical part about webrtc from html 5 rocks website, so i'm not aware too much about coding part of socket connection.</p>
  
  <p>link of code lab is 
  <a href="https://codelabs.developers.google.com/codelabs/webrtc-web/#2" rel="nofollow noreferrer">https://codelabs.developers.google.com/codelabs/webrtc-web/#2</a>
  please visit step 05.</p>
  
  <p>and i didn't understand following part from "main.js" file.</p>
  
  <pre><code>socket.on('message', function(message) {
    console.log('Client received message:', message);
    if (message === 'got user media') {
      maybeStart();
    } else if (message.type === 'offer') {
      if (!isInitiator &amp;&amp; !isStarted) {
        maybeStart();
      }
      pc.setRemoteDescription(new RTCSessionDescription(message));
      doAnswer();
    } else if (message.type === 'answer' &amp;&amp; isStarted) {
      pc.setRemoteDescription(new RTCSessionDescription(message));
    } else if (message.type === 'candidate' &amp;&amp; isStarted) {
      var candidate = new RTCIceCandidate({
        sdpMLineIndex: message.label,
        candidate: message.candidate
      });
      pc.addIceCandidate(candidate);
    } else if (message === 'bye' &amp;&amp; isStarted) {
      handleRemoteHangup();
    }
  });
  </code></pre>
  
  <p>so my quetion is</p>
  
  <p>1)what is message.type === 'offer' and what is offer what kind of string it is? same for 'answer' and 'candidate' also .</p>
  
  <p>and can you gave me flow that how exactly this code works please?</p>