use of org.jivesoftware.smack.PacketCollector in project ecf by eclipse.
the class SyncPacketSend method getReply.
public static Packet getReply(Connection connection, Packet packet, long timeout) throws XMPPException {
PacketFilter responseFilter = new PacketIDFilter(packet.getPacketID());
PacketCollector response = connection.createPacketCollector(responseFilter);
connection.sendPacket(packet);
// Wait up to a certain number of seconds for a reply.
Packet result = response.nextResult(timeout);
// Stop queuing results
response.cancel();
if (result == null) {
throw new XMPPException("No response from server.");
} else if (result.getError() != null) {
throw new XMPPException(result.getError());
}
return result;
}
Aggregations