powered by Jive Software

Adding users to roster and checking availability

Hi,

I have a client that allows users to login. Once they have logged in I want to add a number of users to the the newly registered user. So I have an array that contains these users i.e.:

var buddyArray:Array = new Array();

buddyArray = [“admin@greatwhite”, “i.freestone@greatwhite”];[/i]

then I have a loop that loops through and adds these users:

for (var buddyCount = 0; buddyCount<buddyArray.length; buddyCount++) {

roster.addContact(buddyArray[buddyCount], buddyArray[buddyCount], “Shark”, true);

roster.grantSubscription(buddyArray[buddyCount], true);

}[/i]

This all works fine,

The problem i have is checking when these users are online, it always says unavailable even though they are online. I am checking this but using:

for (var x = 0; x<roster.length; x++) {

userOb = roster.getItemAt(x);

trace("JID: "+userOb.jid);

trace("SHOW: "+userOb.show);

}[/i]

I need to find out which users are online so that I can decide who the messages get sent to.

Any help would be great. I can give more details if needed.

Thanks Iain.

I think the problem comes from the fact the admin@greatwhite and i.freestone@greatwhite users don’'t allow the new users to add them in their roster!

To be seen available, the destination user must accept to have his presence shown to the source user.

The solution could be to make a “special” client which auto-allows users to add them in their roster automatically

Just add sth like that in the “special” client that should auto-allow subscriptions and make sure this client still running (or some wouldn’'t be granted)

roster.addEventListener(“subscriptionRequest”, globalHandler);[/i]

in the globalHandler eventObj.type switch:

case “subscriptionRequest” :

roster.grantSubscription(eventObj.jid, true);

break;

/i

Hi, Thanks for you help boris.

I am still having a problem where when a user changes there status to say for example “away” I get a call from an event listener saying that they have changed there status but to what i do not know.

My event listeners call these:

case “userAvailable” :

trace("userAvailable: "+eventObj.jid);

break;

case “userUnavailable” :

trace("userUnavailable: "+eventObj.jid);

break;

case “presence” :

trace(“presence changed”)

break;[/i]

So when I change the presence to away on my exodus client it pops up in flash trace window saying “presence changed” “userAvailable: i.freestone” but I cannot work out what i need to do to find out what status the exodus client was change dto.

Any help would be great

Iain

case “presence” :

trace("presence changed "+eventObj.data.status)

break;[/i]

Hi,

Thats great cheers.

it was eventObj.data.myStatusNode[/i]

thanks for your help.

Message was edited by:

iainfreestone