for (Iterator cit = getContexts().iterator(); cit.hasNext(); ) {
OctetString context = (OctetString) cit.next();
AgentXPingPDU ping = new AgentXPingPDU(context);
ping.setSessionAttributes(session);
ping.setTransactionID(getNextTransactionID());
PingEvent pingEvent;
try {
AgentXResponseEvent resp =
agentX.send(ping, session.createAgentXTarget(),
session.getPeer().getTransport());
pingEvent = new PingEvent(this, session,
resp.getResponse());
}
catch (IOException ex) {
pingEvent = new PingEvent(this, session, ex);
}
firePinged(pingEvent);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Fired ping event " + pingEvent);
}
if (pingEvent.isCloseSession() || pingEvent.isResetSession()) {
try {
closeSession(session.getSessionID(),
AgentXProtocol.REASON_TIMEOUTS);
if (pingEvent.isResetSession()) {
reopenSession(session);
}
}
catch (IOException ex1) {
}