final String type = response.getAttribute("type");
// Openfire bug: terminal instead of terminate
if ("terminate".equals(type) || "terminal".equals(type)) {
stream.sid = null;
active = false;
eventBus.fireEventFromSource(new ConnectionStatusChangedEvent(ConnectionStatus.disconnected, "disconnected by server"), this);
} else {
if (stream.sid == null) {
initStream(response);
eventBus.fireEventFromSource(new ConnectionStatusChangedEvent(ConnectionStatus.connected), this);
}
shouldCollectResponses = true;
for (final XMLPacket packet : response.getChildren()) {
eventBus.fireEventFromSource(new PacketReceivedEvent(packet), this);
}