do we want this? i think it would be useful, but i'm not 100% convinced.

comments?

Comments

pacheco’s picture

i remember you gave me a good reason about why we can't really know when someone is away:

the person could just be reading the conversation, and so is not away

but if we can find a way to make this distinction it would be a nice feature IMHO

Anonymous’s picture

i remember you gave me a good reason about why we can't really know when someone is away:
the person could just be reading the conversation, and so is not away
but if we can find a way to make this distinction it would be a nice feature IMHO

yes, i remember that :-)

this will require that the users clicks a button or something, that sends an update to the server that sets their status to away (so we probably need another column in the chatroom_online_list table).

then, we need to send this status down to the browser, and update the user's list item class.

moshe weitzman’s picture

i would think that presence info (i.e. online vs away) can be calculated just like who's online block ... if someone is just idly reading a chat room, they might time out though because their updates don't reach the bootstrap (or maybe sess_write() takes care of this).

Anonymous’s picture

i would think that presence info (i.e. online vs away) can be calculated just like who's online block ... if someone is just idly reading a chat room, they might time out though because their updates don't reach the bootstrap (or maybe sess_write() takes care of this).

whether someone is idle or not is not quite the determining factor re. bootstrap - its whether or not a message has been written to the chat.

every message write operation updates the timestamp for the chat, which means we get a cache miss for everyone except the message poster, which leads to an update of all the readers online time, and every 4 update requests, an updated list of who is online is sent down.

have a look at chatroom_read_msgs and chatroomread.php to get a feel for it. this could probably do with an overhaul.

explaining that makes me think it might be worth adding some code to check for user online updates after X cache hits. this will make sure the user list status doesn't stagnate if there haven't been any new messages.

sound like a useful feature?

moshe weitzman’s picture

yes, it is very useful to know who is really in the room even if the room is not aqctive recently ... thanks for the explanation

Anonymous’s picture

first hacky code for this is now in cvs.

db changes are required for this - check the install file to see the new columns.

the css of the user list item is toggled - now we just need some fancy css!

pacheco’s picture

justing i changed:

/**
 * takes an array of online users and formats as js
 */
function chatroom_chat_get_online_list_js($users) {
  $js_array = array();  
  $js = '';
  foreach ($users as $ol_user) {    
    $name = $ol_user->name ? check_plain($ol_user->name) : "guest-{$ol_user->guest_id}";    
    $js .= '{user:"'. $name .'",sessionId:"'. $ol_user->session_id;
    $js .= '",uid:'. $ol_user->uid .',away:'. $ol_user->away .'}';    
    $js_array[] = $js;
  }  
  return '['. implode(',', $js_array) .']';
}

to:

/**
 * takes an array of online users and formats as js
 */
function chatroom_chat_get_online_list_js($users) {
  $js_array = array();  
  foreach ($users as $ol_user) {    
    $name = $ol_user->name ? check_plain($ol_user->name) : "guest-{$ol_user->guest_id}";
    $js = '';
    $js .= '{user:"'. $name .'",sessionId:"'. $ol_user->session_id;
    $js .= '",uid:'. $ol_user->uid .',away:'. $ol_user->away .'}';    
    $js_array[] = $js;
  }  
  return '['. implode(',', $js_array) .']';
}

did i rear you say "fancy" :)
let me see that now...

Anonymous’s picture

good catch paulo!

i've added some more functionality to this, so we're almost there.

- the user list always has the current user at the top

- completed /away and /back basic functionality

/away

toggles css class in user list (though its butt ugly at the moment) and writes a "username is away" message for everyone except the user who went away.

/back

does what you'd expect.

need to pretty up the css away class, and add another way (maybe an icon next to the username? maybe a button in the text submit area? moshe, dave, got any thoughts on this?) to allow users to mark themselves as away.

pacheco’s picture

hmm cool, i was not understanding how users would became away, was think you had figured how to make it automatic...

will think a litlle about UI for this...

Anonymous’s picture

i committed a silly away image, and made the username slightly transparent when away - try it out.

i'd still like a way other than the commands to go away/come back.

pacheco’s picture

justin, commited first UI implementation on that, please review...

Anonymous’s picture

Status: Active » Fixed

hi paulo,

nice work! i like the clock icon and the check box.

i've added a one-liner to link /away and /back then typed in to toggling the box, so i think feature is done for now.

Anonymous’s picture

Status: Fixed » Closed (fixed)