title: firebase realtime database ref (/.info/connected) how does it work
body: <p>I am using</p>
  <pre><code>    firebase.database().ref('.info/connected').on('value', function (snapshot) {
          if (snapshot.val() !== false) {
              console.log(&quot;connected&quot;);
          }
  
      })
  </code></pre>
  <p>To detect the presence of the users. I am trying to understand how does Realtime Database detect if a client is connected or not. It is some black magic for me now. In another words, what are the conditions for a user to be considered <code>true</code> or <code>false</code> under <code>.info/connected</code> field.</p>
  <p>For example, I know in order to be <code>false</code>, the user can leave the page where my web app is found. But what are the conditions exactly? Does it mean if a user executes the <code>firebase.initializeApp(config);</code> codes, and that I run the presence tracking in the same file, then the user is considered to be connected?</p>