// Some client send IQ stanzas with private data to store some
// settings so some confirmation stanzas might be sent back
// let's give the client a few secs for session termination
max_inactivity = 2; // Max pause changed to 2 secs
terminate = true;
Packet command = Command.STREAM_CLOSED.getPacket(null, null,
StanzaType.set, "bosh1");
out_results.offer(command);
}
if (packet.getAttribute(RESTART_ATTR) != null
&& packet.getAttribute(RESTART_ATTR).equals("true")) {
log.fine("Found stream restart instruction: " + packet.toString());
out_results.offer(Command.GETFEATURES.getPacket(null, null,
StanzaType.get, "restart1", null));
}
if (packet.getAttribute(CACHE_ATTR) != null) {
try {
CacheAction action =
CacheAction.valueOf(packet.getAttribute(CACHE_ATTR));
if (cache_on || (action == CacheAction.on)) {
processCache(action, packet);
}
} catch (IllegalArgumentException e) {
log.warning("Incorrect cache action: "
+ packet.getAttribute(CACHE_ATTR));
}
} else {
List<Element> children = packet.getElemChildren(BODY_EL_NAME);
if (children != null) {
for (Element el: children) {
if (el.getXMLNS().equals(BOSH_XMLNS)) {
el.setXMLNS("jabber:client");
}
Packet result = new Packet(el);
if (filterOutPacket(result)) {
log.finest("Sending out packet: " + result.toString());
out_results.offer(result);
} else {
log.finest("Out packet filtered: " + result.toString());
}
}
}
}
} else {
log.info("Duplicated packet: " + packet.toString());
}
} else {
log.warning("[" + connections.size() +
"] Unexpected packet from the network: " + packet.toString());
String er_msg = "Invalid body element";
if (packet.getElemName() != BODY_EL_NAME) {
er_msg += ", incorrect root element name, use " + BODY_EL_NAME;
}
if (packet.getXMLNS() != BOSH_XMLNS) {
er_msg += ", incorrect xmlns, use " + BOSH_XMLNS;
}
try {
Packet error = Authorization.BAD_REQUEST.getResponseMessage(
packet, er_msg, true);
waiting_packets.add(error.getElement());
terminate = true;
Packet command = Command.STREAM_CLOSED.getPacket(null, null,
StanzaType.set, "sess1");
out_results.offer(command);
} catch (PacketErrorTypeException e) {
log.info("Error type and incorrect from bosh client? Ignoring...");
}