I’m writing a XMPP web client using smack and ajax. Everything seems to work, except when I try to implement pollResult.
Within the jsp client, I am calling an Ajax getHTTP request that calls the following method. I am expecting the method to return a String of my latest result. Is this an operative approach? And if not, how should I implement the PacketCollector?
public String getMessages(XMPPConnection connection)
{
String message = null;
PacketTypeFilter filter = new PacketTypeFilter(Message.class);
PacketCollector collector = connection.createPacketCollector(filter);
Packet packet = collector.pollResult();
if (packet instanceof Message) {
Message msg = (Message) packet;
System.out.println(msg.getBody());
message = msg.getBody();
}
return message;
}