title: Detecting Disconnection with PubNub for Javascript
body: <p>I'm creating a person-to-person chat app using PubNub.</p>
  
  <p>Basically, each user is subscribed to their own channel, and then messages are sent by the two parties to each other's channel in an Instant messaging fashion.</p>
  
  <p>The messages are then displayed on the page. I'm using JQuery for this.</p>
  
  <pre><code>pubnub.subscribe({
      restore  : true,
      channel  : 'my_channel',
      callback : function(message) {
          console.log(JSON.stringify(message));
          $('div.chatbox').append('&lt;div&gt;'+message+'&lt;/div&gt;');
      }
  });
  </code></pre>
  
  <p>However, I want to be able to detect when a user has gone offline (I don't really care how they went offline just that the connection to the other party is no longer available). </p>
  
  <p>So if User 1 and User 2 are in conversation, then User 2 goes offline, is there any mechanism on the PubNub side that allows User 1 to check the connection status of User 2? How would I implement this in JS code (skeleton code is ok)?</p>
  
  <p>Thanks in advance.</p>
  
  <p>P.S. I don't want to use Socket.IO</p>