coap: comments1

This commit is contained in:
nick 2024-01-31 13:32:47 +02:00
parent 41adbe1003
commit 537a8be982

View File

@ -488,10 +488,7 @@ public class DefaultCoapClientContext implements CoapClientContext {
Response resp = state.getAdaptor().convertToPublish(msg); Response resp = state.getAdaptor().convertToPublish(msg);
Response response = new Response(ResponseCode.VALID); Response response = new Response(ResponseCode.VALID);
response.setPayload(resp.getPayload()); response.setPayload(resp.getPayload());
if (state.getRpc() == null) { response.getOptions().setObserve(attrs.getObserveCounter().getAndIncrement());
state.setRpc(new TbCoapObservationState(attrs.getExchange(), attrs.getToken()));
}
response.getOptions().setObserve(state.getRpc().getObserveCounter().getAndIncrement());
respond(attrs.getExchange(), response, state.getContentFormat()); respond(attrs.getExchange(), response, state.getContentFormat());
} catch (AdaptorException e) { } catch (AdaptorException e) {
log.trace("Failed to reply due to error", e); log.trace("Failed to reply due to error", e);
@ -522,7 +519,7 @@ public class DefaultCoapClientContext implements CoapClientContext {
boolean conRequest = AbstractSyncSessionCallback.isConRequest(state.getAttrs()); boolean conRequest = AbstractSyncSessionCallback.isConRequest(state.getAttrs());
int requestId = getNextMsgId(); int requestId = getNextMsgId();
Response response = state.getAdaptor().convertToPublish(msg); Response response = state.getAdaptor().convertToPublish(msg);
response.getOptions().setObserve(state.getRpc().getObserveCounter().getAndIncrement()); response.getOptions().setObserve(attrs.getObserveCounter().getAndIncrement());
response.setConfirmable(conRequest); response.setConfirmable(conRequest);
response.setMID(requestId); response.setMID(requestId);
if (conRequest) { if (conRequest) {