Regarding Presence packet in smack

Hi i am developing a small chat application using smack api in the processpacket method i need to send the presence of my roster elements as a packet.I am confusing while getting presence as packet ,at the same time i am able to send message as a packet.So could u plz help regarding How can we send presence as a packet.

And How can subscribe to get the status of the my roster entries

, i am getting presence as

Presence pr=roster,getPresence(entries);

But it is not giving exact presence details.

here i am sending sample code

filter = new AndFilter(new PacketTypeFilter(Message.class), new FromContainsFilter(rentry));

myCollector = con.createPacketCollector(filter);

ontent = null;

content = tfChatMessage.getText().toString();

System.out.println("Content: " + content);

con.createChat(rentry);

msg.setTo(rentry);

msg.setBody(null);

System.out.println("Message body before set, after remove: " + msg.getBody());

msg.setBody(tfChatMessage.getText().toString());

System.out.println("Message body after set: " + msg.getBody());

msg.setType(Message.Type.headline);

MessageEventManager.addNotificationsRequests(msg, true, true, true, true);

public void processPacket(Packet packet)

{

Message message = (Message)packet;

System.out.println(message.getBody()+“is formatted msg”);

System.out.println(message.getFrom()+“is message from”);

chatObj=new ChatClientApp();

System.out.println("presence is "chatObj.presence"packet is "+packet.toXML());

System.out.println(“inside the process packet”);

if (packet instanceof Message)

{

System.out.println(“Inside instance method”);

}

I’m not quite sure what your question is.

Both Presence and Message are extended from org.jivesoftware.smack.packet.Packet, so they can be used in methods accepting a Packet. If you don’t unsderstand this concept of inheritance, look it up, it’s an important part of object oriented programming (OOP).

Ya What u said is correct.But When I compare the packet insatance with the Presence it is not getting the presence value.

do i need to add any filter like below for Presence also

packetFilter filter= new AndFilter(new PacketTypeFilter(Message.class), new FromContainsFilter(rentry));

If no den could u send any sample code to solve this problem.

And i added a list box for status like busy,available etc.wen i change my status it is not reflected in others roster .For that am i need to subscribe to get the updated presence ,if s den how can i set subscroption to get all my roster elements updated status

roster.getPresence(rentry).setType(Presence.Type.subscribed);

roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.accept_all);

roster.setSubscriptionMode(Roster.SubscriptionMode.accept_all);

i wrote these stmts .But still i am confusiung to get updated status.

and i need the code to send a message to contact in my roster.

could u plz help regard this issue

thank u