* @param startDate the starting date of sessions to retrieve.
* @return the chat history associated with a given jid.
* @throws XMPPException if an error occurs while retrieving the AgentChatHistory.
*/
public AgentChatHistory getAgentHistory(String jid, int maxSessions, Date startDate) throws XMPPException {
AgentChatHistory request;
if (startDate != null) {
request = new AgentChatHistory(jid, maxSessions, startDate);
}
else {
request = new AgentChatHistory(jid, maxSessions);
}
request.setType(IQ.Type.GET);
request.setTo(workgroupJID);
PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(request.getPacketID()));
connection.sendPacket(request);
AgentChatHistory response = (AgentChatHistory)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Cancel the collector.
collector.cancel();
if (response == null) {
throw new XMPPException("No response from server.");
}
if (response.getError() != null) {
throw new XMPPException(response.getError());
}
return response;
}