Program: Presence plugin(can''t retrive new status)

Hello,

The Presence plugin for jive messenger is very good for my project.

But I have encountered one error, and can’'t ensure the reason . Please see my code first:

I will catch the status of the account( "a@xm.com" ) every five seconds, but I found the  isUnavailable is in the same status, when I log on or off the client system by the account("a@xm.com"). If I refresh the page, the result is the same.

But if I close the page and open it again, it will show the changed status( the isUnavailable is changed).

I don’'t know the reason, whether Presence service is in that case?

function init()
{
//buttonStatusUpdate() function will execute every 5 seconds
timer = window.setInterval(“buttonStatusUpdate()”,5000);
return false;
}
function buttonStatusUpdate()
{
var cs = "a@xm.com";
var objXmlHttp = new ActiveXObject(“Microsoft.XMLHTTP”);
try
{
var strURL = “http://xm.com:9090/plugins/presence/status?jid=”+ cs + “&type=xml”;
objXmlHttp.open(“GET”, strURL, false);
objXmlHttp.send();
var xmlText = objXmlHttp.responseText;
//if cs is offline, the type=“unavailable” will display in xmlText
//so, we can know the online/offline status through …
var isUnavailable = xmlText.indexOf(’‘type=“unavailable”’’);
alert( xmlText );
if (isUnavailable == -1)
{
alert(“online”);
}
else
{
alert(“offline”);
}
objXmlHttp.close();
}
catch(err)
{
}
}

[/code]

Can everyone give me a explain, and told me how can I catch the changing status every five seconds through Presence plugin but open or close the page!

Hi Scottmx,

this is a common Caching Problem with Microsoft.XMLHTTP !

There are multiple solutions.

Take a look at http://www.zope.org/Members/andym/ASP404 or just google for “Microsoft.XMLHTTP cache” and find looooooooots of articles

Regards

JC

Hi JC_Heyer :

I have done that as you said. Even I have append the code below:

objXmlHttp.open(“GET”, strURL, false);

objXmlHttp.setRequestHeader(“Cache-Control”,“no-cache”);

objXmlHttp.send();

But I found the result is in the same case.

Maybe the presence server the jive messenger plugin support is like that : a presence request from the same page will give the same result, in spite of the presence information is changed.

Is my option right ? Please help me, give me some code, Thanks!!!

Well, I´m not really into Javascript and ActiveX.

Your Problem is NOT that the Presence-Plugin caches your request but your ActiceX-Control. It doesn´t even ask the server for an update.

Try to append something to the url like

var x = random_number(1000000000); < I dont know the Syntax for this>

objXmlHttp.open(“GET”, strURL + ‘’&rand=’’+x, false);

Or drop the Idea of doing it on the Client-Side. You will anyway run into trouble with different Browsers and Versions.

Cheers

JC

HI JC_Heyer:

Thank you very much! I have resolved the problem as your suggestion.

Thanks!!!

Scott,

Why not reward JC with some points for providing such helpful information.

Cheers,

Ryan

Sorry, haha. I haven’'t pay attention to it before, thanks for your remid, ryang

and the points have been pay to JC.

THX