demo/connections/main.js
function onState(data) {
  if (data.status === social.STATUS.OFFLINE) {
    if (users.hasOwnProperty(data.userId)) {
      delete users[data.userId];
    }
  } else {  //Only track non-offline clients
    users[data.userId] = data;
  }
  sendUsers();

  // Handle my state separately
  if (myClientState !== null && data.clientId === myClientState.clientId) {
    view.postMessage({
      event: 'status',
      online: data.status === social.STATUS.ONLINE
    });
    view.postMessage({'height': data.status === social.STATUS.ONLINE ? 384 : 109});
    if (data.status !== social.STATUS.ONLINE) {
      logger.error('got status ' + data.status + ' from social');
      doLogin();
    }
  }
}
function onState(data) {
  if (data.status === social.STATUS.OFFLINE) {
    if (users.hasOwnProperty(data.userId)) {
      delete users[data.userId];
    }
  } else {  //Only track non-offline clients
    users[data.userId] = data;
  }
  sendUsers();

  // Handle my state separately
  if (myClientState !== null && data.clientId === myClientState.clientId) {
    view.postMessage({
      event: 'status',
      online: data.status === social.STATUS.ONLINE
    });
    view.postMessage({'height': data.status === social.STATUS.ONLINE ? 384 : 109});
    if (data.status !== social.STATUS.ONLINE) {
      logger.error('got status ' + data.status + ' from social');
      doLogin();
    }
  }
}
function onState ( data ) { if ( data . status === social . STATUS . OFFLINE ) { if ( users . hasOwnProperty ( data . userId ) ) { delete users [ data . userId ] ; } } else { //Only track non-offline clients users [ data . userId ] = data ; } sendUsers ( ) ; // Handle my state separately if ( myClientState !== null && data . clientId === myClientState . clientId ) { view . postMessage ( { event : 'status' , online : data . status === social . STATUS . ONLINE } ) ; view . postMessage ( { 'height' : data . status === social . STATUS . ONLINE ? 384 : 109 } ) ; if ( data . status !== social . STATUS . ONLINE ) { logger . error ( 'got status ' + data . status + ' from social' ) ; doLogin ( ) ; } } }
On newly online or offline clients, let's update the roster
On newly online or offline clients let s update the roster