This Question is Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (5 pts)
2 Replies Last post: Jan 21, 2008 5:28 AM by 158984  
158984 Bronze 8 posts since
Jan 18, 2008
Currently Being Moderated

Jan 21, 2008 12:32 AM

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");

}

 

 

Sabine Dinis Blochberger Gold 285 posts since
Oct 21, 2005
Currently Being Moderated
Jan 21, 2008 3:54 AM in response to: 158984
Re: Regarding Presence packet in smack

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).

More Like This

  • Retrieving data ...