How to send "Presence" to specific person

I am going to develop a program that I can change and send my own Presence to others automatically. The Presence packets can specific the receiver and the presence that receiver will see. So that different users can see me in a different presence status. How can smack help me to so ?

I have read the Docs of smack, and I found out it cannot send Presence packets with Presence class or specific the receivers.

I would like to ask if there are any smack methods that can do so?

Anybody can help me ? Thanks a lot >.<

The Presence packet class is a subclass of Packet, so it has a setTo()-method just like every other packet.

If I want to update my presence , how can I set it and set-To all people ?

And available function I can use to update presence to all people ?

Thanks a lot

fypcaim,

If you send your presence to the server, it will take care of sending it out to all your contacts. That’‘s the normal mode for XMPP. If you send presence directly to a user, that’'s called directed presence. For full details of how all this works in XMPP, see:

http://www.xmpp.org/rfcs/rfc3921.html#presence

Presence presence = new Presence(Presence.Type.available);

// set presence options here…

connection.sendPacket(presence);

is what you’'d do to send presence to everyone on your roster. Perhaps there should be a Roster.setPresence(Presence) method? That might be a little bit clearer from an end-user perspective.

-Matt

Thanks a lot~

Is that if I don’'t specific the “set-To” of presence packet, it will send to the server and update my status to all ?

but I would to suggest if Smack can add methods for Presence updating and customization

And I have tried to create a Presence packet with Smack version 3 with setFrom and setTo. However, the setTo user cannot show the presence of the presence packet. Is that I have to add the resource (e.g. setTo(fypcaim@hostname/Home) )? Can anyone provide some sample code that update presence of a user ?

Message was edited by: fypcaim