/** * Constructs a new observe relation. * * @param endpoint the observing endpoint * @param resource the observed resource * @param exchange the exchange that tries to establish the observe relation */ public ObserveRelation(ObservingEndpoint endpoint, Resource resource, Exchange exchange) { if (endpoint == null) throw new NullPointerException(); if (resource == null) throw new NullPointerException(); if (exchange == null) throw new NullPointerException(); this.endpoint = endpoint; this.resource = resource; this.exchange = exchange; this.established = false; this.key = getSource().toString() + "#" + exchange.getRequest().getTokenString(); }
/** * Constructs a new observe relation. * * @param endpoint the observing endpoint * @param resource the observed resource * @param exchange the exchange that tries to establish the observe relation */ public ObserveRelation(ObservingEndpoint endpoint, Resource resource, Exchange exchange) { if (endpoint == null) throw new NullPointerException(); if (resource == null) throw new NullPointerException(); if (exchange == null) throw new NullPointerException(); this.endpoint = endpoint; this.resource = resource; this.exchange = exchange; this.established = false; this.key = getSource().toString() + "#" + exchange.getRequest().getTokenString(); }
private void removeNotificationsOf(final ObserveRelation relation) { LOGGER.log(Level.FINE, "Removing all remaining NON-notifications of observe relation with {0}", relation.getSource()); for (Iterator<Response> iterator = relation.getNotificationIterator(); iterator.hasNext(); ) { Response previous = iterator.next(); // notifications are local MID namespace if (previous.hasMID()) { KeyMID idByMID = KeyMID.fromOutboundMessage(previous); exchangeStore.remove(idByMID, relation.getExchange()); } else { previous.cancel(); } iterator.remove(); } }
@Override public void onTimeout() { ObserveRelation relation = exchange.getRelation(); LOGGER.log( Level.INFO, "Notification for token [{0}] timed out. Canceling all relations with source [{1}]", new Object[]{ relation.getExchange().getRequest().getTokenString(), relation.getSource() }); relation.cancelAll(); }
@Override public void onTimeout() { ObserveRelation relation = exchange.getRelation(); LOGGER.info("Notification " + relation.getExchange().getRequest().getTokenString() + " timed out. Cancel all relations with source " + relation.getSource()); relation.cancelAll(); }