code: function onStateChange(e)
      {
          if(scope._conn)
          {
              if(scope._conn.iceConnectionState == "connected")
              {
                  if(scope.onConnected)
                  {
                      scope.onConnected(scope);
                  }
              }
              if(scope._conn.iceConnectionState == "failed" || scope._conn.iceConnectionState == "disconnected")
              {
                  if(scope.onConnectionFail)
                  {
                      scope.onConnectionFail(scope);
                  }
                  if(scope.type == "offer")
                  {
                      scope.createOffer();
                  }
              }
              if(scope._conn.iceConnectionState == "closed")
              {
                  if(scope.onClosed)
                  {
                      scope.onClosed(scope);
                  }
                  scope.dispose();
              }
          }
      }
docs: called when ice connection state is changed