title: xmpp - ping pong
body: <p>So in order to know if there's still an active data connection, I'm sending a ping every like 5 minute interval, and waiting for the server to respond.  So basically, I'm using the iq id as a key on this pinging method.  I'll send a ping, and store the iq id, and i'll say assume that noDataConnection = true.  Now, if I receive a pong with the same iq id, I assume that the connection is alive, so I'll set noDataConnection = false.  However, if there's no data connection, i'll continue to send pings setting noDataConnection = true, and never receiving any so it will remain true unless it recovers and obtained a data connection.</p>
  
  <p>Excerpt from <a href="http://xmpp.org/extensions/xep-0199.html#s2c" rel="nofollow">http://xmpp.org/extensions/xep-0199.html#s2c</a>:
  PING:</p>
  
  <pre><code>&lt;iq from='juliet@capulet.lit/balcony' to='capulet.lit' id='c2s1' type='get'&gt;
    &lt;ping xmlns='urn:xmpp:ping'/&gt;
  &lt;/iq&gt;
  </code></pre>
  
  <p>PONG:</p>
  
  <pre><code>&lt;iq from='capulet.lit' to='juliet@capulet.lit/balcony' id='c2s1' type='result'/&gt;
  </code></pre>
  
  <p>My only concern about this, is what if I received an iq that isn't a result of my ping and my application will assume that noDataConnection = true, since the iq id that it receives doesn't match up to my ping iq id that is sent.  Is there a way to know if the iq that I received is a result of my ping?</p>
  
  <p>Thanks.</p>