Skip to content

Commit

Permalink
Assign MID before register observation.
Browse files Browse the repository at this point in the history
Signed-off-by: Achim Kraus <achim.kraus@bosch-si.com>
  • Loading branch information
Achim Kraus committed Oct 2, 2018
1 parent 35a2d12 commit e9cdd8b
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* Achim Kraus (Bosch Software Innovations GmbH) - change ExchangeObserver
* to RemoveHandler
* remove "is last", not longer meaningful
* Achim Kraus (Bosch Software Innovations GmbH) - assign mid before register observation
******************************************************************************/
package org.eclipse.californium.core.network;

Expand All @@ -59,7 +60,6 @@
import java.util.concurrent.Executor;

import org.eclipse.californium.core.coap.EmptyMessage;
import org.eclipse.californium.core.coap.Message;
import org.eclipse.californium.core.coap.Request;
import org.eclipse.californium.core.coap.Response;
import org.eclipse.californium.core.coap.Token;
Expand Down Expand Up @@ -112,6 +112,7 @@ public void sendRequest(final Exchange exchange) {
// for observe request.
Request request = exchange.getCurrentRequest();
if (request.isObserve() && 0 == exchange.getFailedTransmissionCount()) {
exchangeStore.assignMessageId(request);
registerObserve(request);
}

Expand Down Expand Up @@ -255,7 +256,7 @@ public Exchange receiveResponse(final Response response) {
EndpointContext context = exchange.getEndpointContext();
Request currentRequest = exchange.getCurrentRequest();
int requestMid = currentRequest.getMID();
if (context == null || requestMid == Message.NONE) {
if (context == null) {
LOGGER.debug("ignoring response {}, request pending to sent!", response);
return null;
}
Expand Down

0 comments on commit e9cdd8b

Please sign in to comment.