try {
logger.log(Level.FINEST, "Response is SSE - about to read events");
closeSse = false;
ProprietaryReader<GfSseEventReceiver> reader = new GfSseEventReceiverProprietaryReader();
GfSseEventReceiver eventReceiver = reader.readFrom(urlConnection.getInputStream(), resultMediaType);
GfSseInboundEvent event;
String instanceId = null;
do {
event = eventReceiver.readEvent();
if (event != null) {
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "Event: {0}", event.getName());
}
fireEvent(event.getName(), event);
if (AdminCommandState.EVENT_STATE_CHANGED.equals(event.getName())) {
AdminCommandState acs = event.getData(AdminCommandState.class, MEDIATYPE_JSON);
if (acs.getId() != null) {
instanceId = acs.getId();
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "Command instance ID: {0}", instanceId);
}