@Override public void receiveRequest(Request request) { LOGGER.log(Level.INFO, "{0}:{1} ==> req {2}", new Object[]{request.getSource(), request.getSourcePort(), request}); }
@Override public void receiveRequest(Request request) { LOGGER.log(Level.INFO, "{0}", request.getSource()); }
@Override public void receiveRequest(Request request) { LOGGER.info(String.format("%s:%d ==> req %s", request.getSource(), request.getSourcePort(), request)); }
@Override public void receiveRequest(Request request) { LOGGER.log(Level.INFO, "{0}", request.getSource()); }
private DTLSSession getSession(Request request) { return connector.getSessionByAddress(new InetSocketAddress(request.getSource(), request.getSourcePort())); } }
/** * Gets the source address of the request. * * @return the source address */ public InetAddress getSourceAddress() { return exchange.getRequest().getSource(); }
/** * Sends the specified response over the same endpoint as the request has * arrived. * * @param response the response */ public void sendResponse(Response response) { response.setDestination(request.getSource()); response.setDestinationPort(request.getSourcePort()); setResponse(response); endpoint.sendResponse(this, response); }
/** * Gets the source address of the request. * * @return the source address */ public InetAddress getSourceAddress() { return exchange.getRequest().getSource(); }
/** * Creates a response to the specified request with the specified response * code. The destination address of the response is the source address of * the request. * Type and MID are usually set automatically by the {@link ReliabilityLayer}. * The token is set automatically by the {@link Matcher}. * * @param request * the request * @param code * the code * @return the response */ public static Response createResponse(Request request, ResponseCode code) { Response response = new Response(code); response.setDestination(request.getSource()); response.setDestinationPort(request.getSourcePort()); return response; }
/** * Creates a response to the specified request with the specified response * code. The destination address of the response is the source address of * the request. * Type and MID are usually set automatically by the {@link ReliabilityLayer}. * The token is set automatically by the {@link Matcher}. * * @param request * the request * @param code * the code * @return the response */ public static Response createResponse(Request request, ResponseCode code) { Response response = new Response(code); response.setDestination(request.getSource()); response.setDestinationPort(request.getSourcePort()); return response; }
/** * Sends the specified response over the same endpoint as the request has * arrived. * * @param response the response */ public void sendResponse(Response response) { response.setDestination(request.getSource()); response.setDestinationPort(request.getSourcePort()); setResponse(response); endpoint.sendResponse(this, response); }
@Override public void deliverRequest(final Exchange exchange) { Request request = exchange.getRequest(); List<String> path = request.getOptions().getUriPath(); final Resource resource = findResource(path); if (resource != null) { checkForObserveOption(exchange, resource); // Get the executor and let it process the request Executor executor = resource.getExecutor(); if (executor != null) { exchange.setCustomExecutor(); executor.execute(new Runnable() { public void run() { resource.handleRequest(exchange); } }); } else { resource.handleRequest(exchange); } } else { LOGGER.info("Did not find resource " + path.toString() + " requested by " + request.getSource()+":"+request.getSourcePort()); exchange.sendResponse(new Response(ResponseCode.NOT_FOUND)); } }
objectLinks = LinkObject.parse(request.getPayload()); UpdateRequest updateRequest = new UpdateRequest(registrationId, request.getSource(), request.getSourcePort(), lifetime, smsNumber, binding, objectLinks);
@Override public void handleDELETE(CoapExchange exchange) { LOG.debug("DELETE received : {}", exchange.advanced().getRequest()); List<String> uri = exchange.getRequestOptions().getUriPath(); if (uri != null && uri.size() == 2 && RESOURCE_NAME.equals(uri.get(0))) { DeregisterRequest deregisterRequest = new DeregisterRequest(uri.get(1)); LwM2mResponse deregisterResponse = registrationHandler.deregister(deregisterRequest); exchange.respond(fromLwM2mCode(deregisterResponse.getCode())); if (exchange.advanced().getEndpoint() instanceof SecureEndpoint && deregisterResponse.getCode().equals(org.eclipse.leshan.ResponseCode.DELETED)) { // clean the DTLS Session Request request = exchange.advanced().getRequest(); ((SecureEndpoint) exchange.advanced().getEndpoint()).getDTLSConnector().close( new InetSocketAddress(request.getSource(), request.getSourcePort())); } } else { LOG.debug("Invalid deregistration"); exchange.respond(ResponseCode.NOT_FOUND); } }
final InetSocketAddress source = new InetSocketAddress(request.getSource(), request.getSourcePort()); LOGGER.info("Initiate an observe relation between " + request.getSource() + ":" + request.getSourcePort() + " and resource " + resource.getURI()); final ObservingEndpoint remote = observeManager.findObservingEndpoint(source);
if (request.getCode() != Code.GET) return; InetSocketAddress source = new InetSocketAddress(request.getSource(), request.getSourcePort()); LOGGER.finer("Initiate an observe relation between " + request.getSource() + ":" + request.getSourcePort() + " and resource " + resource.getURI()); ObservingEndpoint remote = observeManager.findObservingEndpoint(source); ObserveRelation relation = new ObserveRelation(remote, resource, exchange);
InetSocketAddress source = new InetSocketAddress(request.getSource(), request.getSourcePort()); new Object[]{request.getSource(), request.getSourcePort(), resource.getURI()}); ObservingEndpoint remote = observeManager.findObservingEndpoint(source); ObserveRelation relation = new ObserveRelation(remote, resource, exchange);
return exchange; } else { Exchange.KeyUri idByUri = new Exchange.KeyUri(request.getURI(), request.getSource().getAddress(), request.getSourcePort()); LOGGER.log(Level.FINE, "Looking up ongoing exchange for {0}", idByUri);
private Response responseFor(final Request request) { Response response = new Response(ResponseCode.CONTENT); response.setMID(request.getMID()); response.setToken(request.getToken()); response.setBytes(new byte[]{}); response.setSource(request.getDestination()); response.setSourcePort(request.getDestinationPort()); response.setDestination(request.getSource()); response.setDestinationPort(request.getSourcePort()); return response; } }
private static Response responseFor(final Request request) { Response response = new Response(ResponseCode.CONTENT); response.setMID(request.getMID()); response.setToken(request.getToken()); response.setBytes(new byte[]{}); response.setSource(request.getDestination()); response.setSourcePort(request.getDestinationPort()); response.setDestination(request.getSource()); response.setDestinationPort(request.getSourcePort()); return response; } }