@Override public void onError(Exception e) { handlerError(destination.getEndpoint(), ticket, e); } });
@Override public void onResponse(LwM2mResponse response) { handleResponse(destination.getEndpoint(), ticket, response); } }, new ErrorCallback() {
@Override public void onResponse(LwM2mResponse response) { handleResponse(destination.getEndpoint(), ticket, response); } }, new ErrorCallback() {
@Override public void unregistered(Registration registration, Collection<Observation> observations, boolean expired, Registration newReg) { String jReg = EventServlet.this.gson.toJson(registration); sendEvent(EVENT_DEREGISTRATION, jReg, registration.getEndpoint()); }
/** * Returns the {@link PresenceStatus} object associated with the given endpoint name. * * @param reg The client's registration object. * @return The {@link PresenceStatus} object. */ private PresenceStatus getPresenceStatusObject(Registration reg) { return clientStatusList.get(reg.getEndpoint()); }
@Override public void updated(RegistrationUpdate update, Registration updatedRegistration, Registration previousRegistration) { String jReg = EventServlet.this.gson.toJson(updatedRegistration); sendEvent(EVENT_UPDATED, jReg, updatedRegistration.getEndpoint()); }
@Override public void registered(Registration registration, Registration previousReg, Collection<Observation> previousObsersations) { String jReg = EventServlet.this.gson.toJson(registration); sendEvent(EVENT_REGISTRATION, jReg, registration.getEndpoint()); }
/** * Removes the {@link PresenceStatus} object associated with the client from the list. * * @param reg the client's registration object. */ public void removePresenceStatusObject(Registration reg) { clientStatusList.remove(reg.getEndpoint()); }
/** * Computes a hash code for this client. * * @return the hash code based on the <em>endpoint</em> property */ @Override public int hashCode() { return getEndpoint().hashCode(); }
@Override public void onSleeping(Registration registration) { String data = new StringBuilder("{\"ep\":\"").append(registration.getEndpoint()).append("\"}").toString(); sendEvent(EVENT_SLEEPING, data, registration.getEndpoint()); }
@Override public void onAwake(Registration registration) { String data = new StringBuilder("{\"ep\":\"").append(registration.getEndpoint()).append("\"}").toString(); sendEvent(EVENT_AWAKE, data, registration.getEndpoint()); } };
@Override public void unregistered(Registration registration, Collection<Observation> observations, boolean expired, Registration newReg) { try (Jedis j = pool.getResource()) { // create registration entry j.del((EP_UID + registration.getEndpoint()).getBytes()); } }
@Override public boolean isClientAwake(Registration registration) { PresenceStatus presenceStatus = clientStatusList.get(registration.getEndpoint()); if (presenceStatus == null) { return false; } return presenceStatus.isClientAwake(); }
@Override public Registration isAuthorized(UplinkRequest<?> request, Registration registration, Identity senderIdentity) { // do we have security information for this client? SecurityInfo expectedSecurityInfo = null; if (securityStore != null) expectedSecurityInfo = securityStore.getByEndpoint(registration.getEndpoint()); if (securityChecker.checkSecurityInfo(registration.getEndpoint(), senderIdentity, expectedSecurityInfo)) { return registration; } else { return null; } } }
private void removeAddrIndex(Jedis j, Registration registration) { byte[] regAddrKey = toRegAddrKey(registration.getSocketAddress()); byte[] epFromAddr = j.get(regAddrKey); if (Arrays.equals(epFromAddr, registration.getEndpoint().getBytes(UTF_8))) { j.del(regAddrKey); } }
private void removeAddrIndex(Jedis j, Registration registration) { byte[] regAddrKey = toRegAddrKey(registration.getSocketAddress()); byte[] epFromAddr = j.get(regAddrKey); if (Arrays.equals(epFromAddr, registration.getEndpoint().getBytes(UTF_8))) { j.del(regAddrKey); } }
@Override public void onResponse(Observation observation, Registration registration, ObserveResponse response) { if (LOG.isDebugEnabled()) { LOG.debug("Received notification from [{}] containing value [{}]", observation.getPath(), response.getContent().toString()); } if (registration != null) { String data = new StringBuilder("{\"ep\":\"").append(registration.getEndpoint()).append("\",\"res\":\"") .append(observation.getPath().toString()).append("\",\"val\":") .append(gson.toJson(response.getContent())).append("}").toString(); sendEvent(EVENT_NOTIFICATION, data, registration.getEndpoint()); } }
@Override public void updated(RegistrationUpdate update, Registration updatedRegistration, Registration previousRegistration) { try (Jedis j = pool.getResource()) { // create registration entry byte[] k = (EP_UID + updatedRegistration.getEndpoint()).getBytes(); j.set(k, instanceUID.getBytes()); j.expire(k, updatedRegistration.getLifeTimeInSec().intValue()); } }
@Override public void registered(Registration registration, Registration previousReg, Collection<Observation> previousObsersations) { try (Jedis j = pool.getResource()) { // create registration entry byte[] k = (EP_UID + registration.getEndpoint()).getBytes(); j.set(k, instanceUID.getBytes()); j.expire(k, registration.getLifeTimeInSec().intValue()); } }
@Override public void visit(WriteRequest request) { if (coapResponse.isError()) { // handle error response: lwM2mresponse = new WriteResponse(toLwM2mResponseCode(coapResponse.getCode()), coapResponse.getPayloadString(), coapResponse); } else if (coapResponse.getCode() == org.eclipse.californium.core.coap.CoAP.ResponseCode.CHANGED) { // handle success response: lwM2mresponse = new WriteResponse(ResponseCode.CHANGED, null, coapResponse); } else { // handle unexpected response: handleUnexpectedResponseCode(registration.getEndpoint(), request, coapResponse); } }