Smack (3.0.0 -- March 31, 2007) and Processing Incoming Packets

Hi, my problem is that I want to get incoming messages form different users and process them, if they send add, remove, update, etc I wil do different things. I’‘m adding them to different lists to know the commands they sent. I login, receive the messages but I’‘m doing something bad when I answer because nothing happens. So if anyone could help me explaining how should I do this it will be great :D. I already read http://www.igniterealtime.org/builds/smack/docs/latest/documentation/processing. html , but it seems I didn’'t understand it well…

my code to process messages is:

public void processPacket(Packet packet) {

Message message = (Message) packet;

int indexB = packet.getFrom().indexOf("/");

String to = packet.getFrom().substring(0, indexB);

String receivedMess = message.getBody();

System.out.println(packet.getFrom());

if ((!acceptingReplies.contains(to)) && (receivedMess.equals(“add”))){

acceptingReplies.add(to);

System.out.println(acceptingReplies);

return;

}
else if ((acceptingReplies.contains(to)) && (receivedMess.equals(“remove”))){

acceptingReplies.remove(to);

System.out.println(acceptingReplies);

return;

}
else if ((!acceptingReplies.contains(to)) && (receivedMess.equals(“remove”))){

System.out.println(acceptingReplies);

return;

}
else if (acceptingReplies.contains(to)){

System.out.println(acceptingReplies);

return;

}

System.out.println(acceptingReplies);

return;

}

So, where and how should I send the answers?

tks.

problem solved

Ok, glad to hear that you fixed it. One other thing you might look at is the StringUtils methods to parse out the to and from values.

-Matt

ok. tks