boolean found = false; for (Notification oldNotification : notifications) { if (oldNotification.getSeqNumber() == newNotification.getSeqNumber()) { found = true; break; } else { LOG.debug("Notification with seq number {} is already present in response", newNotification.getSeqNumber());
private static NotificationSyncResponse convert(NotificationServerSync source) { if (source == null) { return null; } NotificationSyncResponse sync = new NotificationSyncResponse(); sync.setResponseStatus(convert(source.getResponseStatus())); if (source.getAvailableTopics() != null) { List<Topic> topics = new ArrayList<>(source.getAvailableTopics().size()); for (org.kaaproject.kaa.server.sync.Topic topic : source.getAvailableTopics()) { topics.add(new Topic( topic.getIdAsLong(), topic.getName(), convert(topic.getSubscriptionType()))); } sync.setAvailableTopics(topics); } if (source.getNotifications() != null) { List<Notification> notifications = new ArrayList<>(source.getNotifications().size()); for (org.kaaproject.kaa.server.sync.Notification notification : source.getNotifications()) { notifications.add(new Notification( notification.getTopicIdAsLong(), convert(notification.getType()), notification.getUid(), notification.getSeqNumber(), notification.getBody())); } sync.setNotifications(notifications); } return sync; }
buf.putShort((short) notificationSync.getNotifications().size()); for (Notification nf : notificationSync.getNotifications()) { buf.putInt((nf.getSeqNumber() != null) ? nf.getSeqNumber() : 0); buf.put(nf.getType() == NotificationType.SYSTEM ? SYSTEM : CUSTOM); buf.put(NOTHING);