use of org.bimserver.endpoints.EndPoint in project BIMserver by opensourceBIM.
the class NotificationRegistryServiceImpl method unregisterChangeProgressOnRevision.
@Override
public void unregisterChangeProgressOnRevision(Long endPointId, Long poid, Long roid) throws ServerException, UserException {
ChangeProgressTopicOnRevisionTopic changeProgressOnProjectTopic = getBimServer().getNotificationsManager().getChangeProgressOnRevisionTopic(poid, roid);
EndPoint endPoint = getEndPoint(endPointId);
try {
changeProgressOnProjectTopic.unregister(endPoint);
} catch (TopicRegisterException e) {
handleException(e);
}
}
use of org.bimserver.endpoints.EndPoint in project BIMserver by opensourceBIM.
the class ProgressTopic method updateProgress.
protected synchronized void updateProgress(final LongActionState state) {
try {
// Actually we should be keeping track of when we last sent a message to A SPECIFIC ENDPOINT, this way, new endpoints won't receive the message rights away
boolean sendMessage = lastSent == -1L || (System.nanoTime() - lastSent > RATE_LIMIT_NANO_SECONDS && state.getProgress().intValue() != lastProgress.getProgress().intValue());
sendMessage |= state.getProgress() == 100;
sendMessage |= state.getState() == ActionState.FINISHED;
sendMessage |= state.getState() == ActionState.AS_ERROR;
sendMessage |= lastProgress != null && lastProgress.getStage() != state.getStage();
sendMessage |= lastProgress != null && ((lastProgress.getTitle() == null && state.getTitle() != null) || !lastProgress.getTitle().equals(state.getTitle()));
if (sendMessage) {
try {
// System.out.println("Sending " + state.getProgress() + ", " + state.getState() + ", " + state.getTitle() + " to " + getEndPoints().size());
map(new Mapper() {
@Override
public void map(EndPoint endPoint) throws UserException, ServerException, BimserverDatabaseException {
try {
endPoint.getNotificationInterface().progress(key.getId(), new SConverter().convertToSObject(state));
} catch (Exception e) {
LOGGER.error("", e);
}
}
});
} catch (Exception e) {
LOGGER.error("", e);
}
lastProgress = state;
lastSent = System.nanoTime();
} else {
// System.out.println("Skipping " + state.getProgress() + ", " + state.getState() + ", " + state.getTitle());
}
} catch (Exception e) {
LOGGER.error("", e);
}
}
Aggregations