Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > BOOK: Professional XMPP Programming with JavaScript and jQuery
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional XMPP Programming with JavaScript and jQuery
This is the forum to discuss the Wrox book Professional XMPP Programming with JavaScript and jQuery by Jack Moffitt; ISBN: 978-0-470-54071-8
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional XMPP Programming with JavaScript and jQuery section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 13th, 2010, 07:13 AM
Registered User
 
Join Date: Sep 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem getting the online presence list after attaching

Hello Jack,
I have been reading your book and used it in order to build a chat application similar to the one on facebook. First of all, I would like to thank you for having written this helpful and well documented book!
After having read the 12th chapter, I decided to also use "attach" in order to prevent the user from reentering his credentials when refreshing or visiting another page where the chat application is available. I saved the JID, SID and RID in cookies when the unload event occurred and then reread them when necessary and attaching to the old connection.
Everything worked just fine, but I experience a problem regarding the online presence list. When unloading, I do not send any presence stanza having the type "unavailable" because I do not want the other users to see that I go offline and come back online every time I do a page refresh. However, after attaching and requesting the roster again I can only see a list with all the contacts appearing offline (although some of them are for sure online). The problem is that although I send the initial presence information, when attaching the other contacts do not send their presence stanzas because in their view I am still online, as before attaching.
My question is if I can somehow request the other users to send their presence stanza, without actually announcing them that I go offline and then send again initial presence information that normally triggers them into sending me their presence stanza.
I tried to pause and resume the connection but the situation stays the same. I attach the code that I used when unloading the page and loading it again.
I would be really grateful for your answer, because this problem is bugging me for some while and I would really need to know if what I want is possible or not and unfortunately I was not able to find an answer anywhere else..



$(window).unload(function() {
connection.pause();
if( connection != null ){
set_cookie();
}else{

createCookie("cookieJid","",-1);
createCookie("cookieSid","",-1);
createCookie("cookieRid","",-1);

}
});




$(document).ready(function() {
var con = new Strophe.Connection("http://bosh.metajack.im:5280/xmpp-httpbind" );
var cookieJid = readCookie( "cookieJid" );
var cookieSid = readCookie( "cookieSid" );
var cookieRid = readCookie( "cookieRid" );


if( ( cookieSid != null ) && ( cookieSid != '') ){
con.attach( cookieJid, cookieSid, cookieRid , null );
}
else{
con=null;
}
if (con!=null){

connection = con;
triggerConnected();

}
});




triggerConnected: function(){

$("#login_dialog").html('');
$("#login_dialog").append("<ul style=\"overflow:auto\"></ul>");

var iq = $iq({type: 'get'}).c('query', {xmlns: 'jabber:iq:roster'});

connection.resume();
connection.sendIQ(iq, on_roster);


connection.addHandleron_message, null, "message", "chat");
}





on_roster : function (iq){


$(iq).find('item').each(function () {

//etc

});


connection.addHandler( on_presence, null, "presence");
connection.send(null);
connection.send($pres());

}

Thak you very much for your time!

Last edited by anamaria; September 13th, 2010 at 07:30 AM..
  #2 (permalink)  
Old September 22nd, 2010, 03:47 PM
Registered User
 
Join Date: Sep 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,
Sorry for insisting but I am really interested in the response to this question. And until now I didn't find any answer so I have no idea how to continue..
I would be more than happy if you could help me..please! :)
  #3 (permalink)  
Old December 5th, 2010, 01:24 PM
Wrox Author
Points: 702, Level: 10
Points: 702, Level: 10 Points: 702, Level: 10 Points: 702, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

Quote:
Originally Posted by anamaria View Post
Everything worked just fine, but I experience a problem regarding the online presence list. When unloading, I do not send any presence stanza having the type "unavailable" because I do not want the other users to see that I go offline and come back online every time I do a page refresh. However, after attaching and requesting the roster again I can only see a list with all the contacts appearing offline (although some of them are for sure online).
Your application must preserve some amount of state about the connection. One of these bits of state is the JID, SID, and RID. Another is the presence status of contacts.

Quote:
My question is if I can somehow request the other users to send their presence stanza, without actually announcing them that I go offline and then send again initial presence information that normally triggers them into sending me their presence stanza.
You can send presence probes manually to everyone on your roster, but that is not really advisable. People may be changing pages a lot, and sending lots of duplicate probes is probably not going to scale well.

Use local storage to store critical application state on the client side or find some way to store this server side (AJAX, XMPP's private xml storage, etc).
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dealing with the presence of an XML tag rather tha Mike250 SQL Server 2005 1 June 6th, 2008 03:50 PM
How to Test for Presence of a File BrianWren Visual Basic 2005 Basics 7 April 30th, 2008 05:44 PM
Testing for presence of a variable rushman XSLT 2 September 12th, 2007 10:36 AM
Attaching database & DBCC CHECKTABLE problem... seananderson SQL Server 2000 5 April 2nd, 2007 08:29 AM
How to check for the presence of an attribute dsekar_nat XSLT 2 July 27th, 2006 05:04 AM



All times are GMT -4. The time now is 07:22 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.