Source:
<code>public void onNotification(Request coapRequest, Response coapResponse) { LOG.trace("notification received for request {}: {}", coapRequest, coapResponse); if (listeners.isEmpty()) return; String regid = coapRequest.getUserContext().get(CTX_REGID); Observation observation = registrationStore.getObservation(regid, coapResponse.getToken()); if (observation == null) { LOG.error("Unexpected error: Unable to find observation with token for registration {}", observation, coapResponse.getToken()); return; } Registration registration = registrationStore.getRegistration(observation.getRegistrationId()); if (registration == null) { LOG.error("Unexpected error: There is no registration with id for this observation {}", observation.getRegistrationId(), observation); return; } <START> clientStatusTracker.setClientOnline(registration); <END> try { LwM2mModel model = modelProvider.getObjectModel(registration); ObserveResponse response = createObserveResponse(observation, model, coapResponse); for (ObservationListener listener : listeners) { listener.onResponse(observation, registration, response); } } catch (InvalidResponseException e) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Invalid notification for observation [%s]", observation), e); } for (ObservationListener listener : listeners) { listener.onError(observation, registration, e); } } catch (RuntimeException e) { if (LOG.isErrorEnabled()) { LOG.error(String.format("Unable to handle notification for observation [%s]", observation), e); } for (ObservationListener listener : listeners) { listener.onError(observation, registration, e); } } }</code><technical_language>I create a clientStatusTracker attribute in LeshanServer add a ObservationListener call this clientStatusTracker.setClientOnline(registration)</technical_language>

Target:
public void onNotification(Request coapRequest, Response coapResponse) { LOG.trace("notification received for request {}: {}", coapRequest, coapResponse); if (listeners.isEmpty()) return; String regid = coapRequest.getUserContext().get(CTX_REGID); Observation observation = registrationStore.getObservation(regid, coapResponse.getToken()); if (observation == null) { LOG.error("Unexpected error: Unable to find observation with token for registration {}", observation, coapResponse.getToken()); return; } Registration registration = registrationStore.getRegistration(observation.getRegistrationId()); if (registration == null) { LOG.error("Unexpected error: There is no registration with id for this observation {}", observation.getRegistrationId(), observation); return; } try { LwM2mModel model = modelProvider.getObjectModel(registration); ObserveResponse response = createObserveResponse(observation, model, coapResponse); for (ObservationListener listener : listeners) { listener.onResponse(observation, registration, response); } } catch (InvalidResponseException e) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Invalid notification for observation [%s]", observation), e); } for (ObservationListener listener : listeners) { listener.onError(observation, registration, e); } } catch (RuntimeException e) { if (LOG.isErrorEnabled()) { LOG.error(String.format("Unable to handle notification for observation [%s]", observation), e); } for (ObservationListener listener : listeners) { listener.onError(observation, registration, e); } } }