/** * Cancels all observe relations that this endpoint has established with * resources from this server. */ public void cancelAll() { for (ObserveRelation relation:relations) relation.cancel(); }
/** * Cancels all observe relations that this endpoint has established with * resources from this server. */ public void cancelAll() { for (ObserveRelation relation:relations) relation.cancel(); }
/** * Cancel all observe relations to CoAP clients. */ public void clearObserveRelations() { for (ObserveRelation relation:observeRelations) { relation.cancel(); } }
/** * Cancel all observe relations to CoAP clients. */ public void clearObserveRelations() { for (ObserveRelation relation:observeRelations) { relation.cancel(); } }
/** * Adds the specified observe relation. * * @param relation the observe relation * @return true, if a old relation was replaced by the provided one, * false, if the provided relation was added. */ public boolean add(ObserveRelation relation) { if (relation == null) throw new NullPointerException(); ObserveRelation previous = observeRelations.put(relation.getKey(), relation); if (null != previous) { previous.cancel(); return true; } return false; }
/** * Adds the specified observe relation. * * @param relation the observe relation * @return true, if a old relation was replaced by the provided one, * false, if the provided relation was added. */ public boolean add(ObserveRelation relation) { if (relation == null) throw new NullPointerException(); ObserveRelation previous = observeRelations.put(relation.getKey(), relation); if (null != previous) { previous.cancel(); return true; } return false; }
/** * Remove all observe relations to CoAP clients and notify them that the * observe relation has been canceled. * * @param code * the error code why the relation was terminated * (e.g., 4.04 after deletion) */ public void clearAndNotifyObserveRelations(ResponseCode code) { /* * draft-ietf-core-observe-08, chapter 3.2 Notification states: * In the event that the resource changes in a way that would cause * a normal GET request at that time to return a non-2.xx response * (for example, when the resource is deleted), the server sends a * notification with a matching response code and removes the client * from the list of observers. * This method is called, when the resource is deleted. */ for (ObserveRelation relation:observeRelations) { relation.cancel(); relation.getExchange().sendResponse(new Response(code)); } }
/** * Remove all observe relations to CoAP clients and notify them that the * observe relation has been canceled. * * @param code * the error code why the relation was terminated * (e.g., 4.04 after deletion) */ public void clearAndNotifyObserveRelations(ResponseCode code) { /* * draft-ietf-core-observe-08, chapter 3.2 Notification states: * In the event that the resource changes in a way that would cause * a normal GET request at that time to return a non-2.xx response * (for example, when the resource is deleted), the server sends a * notification with a matching response code and removes the client * from the list of observers. * This method is called, when the resource is deleted. */ for (ObserveRelation relation:observeRelations) { relation.cancel(); relation.getExchange().sendResponse(new Response(code)); } }
@Override public void receiveEmptyMessage(Exchange exchange, EmptyMessage message) { // NOTE: We could also move this into the MessageObserverAdapter from // sendResponse into the method rejected(). if (message.getType() == Type.RST && exchange.getOrigin() == Origin.REMOTE) { // The response has been rejected ObserveRelation relation = exchange.getRelation(); if (relation != null) { relation.cancel(); } // else there was no observe relation ship and this layer ignores the rst } super.receiveEmptyMessage(exchange, message); }
@Override public void receiveEmptyMessage(final Exchange exchange, final EmptyMessage message) { // NOTE: We could also move this into the MessageObserverAdapter from // sendResponse into the method rejected(). if (message.getType() == Type.RST && exchange.getOrigin() == Origin.REMOTE) { // The response has been rejected ObserveRelation relation = exchange.getRelation(); if (relation != null) { relation.cancel(); } // else there was no observe relation ship and this layer ignores // the rst } upper().receiveEmptyMessage(exchange, message); }
@Override public void sendResponse(final Exchange exchange, final Response response) { final ObserveRelation relation = exchange.getRelation(); if (relation != null && relation.isEstablished()) { if (!response.getOptions().hasObserve()) { /* response for cancel request */ relation.cancel(); response.setLast(true); } else { response.setLast(false); } } // else no observe was requested or the resource does not allow it lower().sendResponse(exchange, response); }
final ObserveRelation relation = observeManager.getRelation(source, request.getToken()); if (relation != null) { relation.cancel();
relation.cancel();
if (relation!=null) relation.cancel();
final ObserveRelation relation = observeManager.getRelation(source, request.getToken()); if (relation != null) { relation.cancel();
relation.cancel();
LOGGER.fine("Response has error code "+response.getCode()+" and must be sent as CON"); response.setType(Type.CON); relation.cancel(); } else {
LOGGER.log(Level.FINE, "Response has error code {0} and must be sent as CON", response.getCode()); response.setType(Type.CON); relation.cancel(); } else {