org.eclipse.californium.core.coap.Request.getSource()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(255)

本文整理了Java中org.eclipse.californium.core.coap.Request.getSource方法的一些代码示例,展示了Request.getSource的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getSource方法的具体详情如下:
包路径:org.eclipse.californium.core.coap.Request
类名称:Request
方法名:getSource

Request.getSource介绍

暂无

代码示例

代码示例来源:origin: eclipse/californium

  1. @Override
  2. public void receiveRequest(Request request) {
  3. LOGGER.log(Level.INFO, "{0}:{1} ==> req {2}", new Object[]{request.getSource(), request.getSourcePort(), request});
  4. }

代码示例来源:origin: org.eclipse.californium/californium-core

  1. @Override
  2. public void receiveRequest(Request request) {
  3. LOGGER.log(Level.INFO, "{0}", request.getSource());
  4. }

代码示例来源:origin: org.eclipse.californium/californium-core

  1. @Override
  2. public void receiveRequest(Request request) {
  3. LOGGER.info(String.format("%s:%d ==> req %s", request.getSource(), request.getSourcePort(), request));
  4. }

代码示例来源:origin: eclipse/californium

  1. @Override
  2. public void receiveRequest(Request request) {
  3. LOGGER.log(Level.INFO, "{0}", request.getSource());
  4. }

代码示例来源:origin: org.eclipse.leshan/leshan-server-cf

  1. private DTLSSession getSession(Request request) {
  2. return connector.getSessionByAddress(new InetSocketAddress(request.getSource(), request.getSourcePort()));
  3. }
  4. }

代码示例来源:origin: eclipse/californium

  1. /**
  2. * Gets the source address of the request.
  3. *
  4. * @return the source address
  5. */
  6. public InetAddress getSourceAddress() {
  7. return exchange.getRequest().getSource();
  8. }

代码示例来源:origin: eclipse/californium

  1. /**
  2. * Sends the specified response over the same endpoint as the request has
  3. * arrived.
  4. *
  5. * @param response the response
  6. */
  7. public void sendResponse(Response response) {
  8. response.setDestination(request.getSource());
  9. response.setDestinationPort(request.getSourcePort());
  10. setResponse(response);
  11. endpoint.sendResponse(this, response);
  12. }

代码示例来源:origin: org.eclipse.californium/californium-core

  1. /**
  2. * Gets the source address of the request.
  3. *
  4. * @return the source address
  5. */
  6. public InetAddress getSourceAddress() {
  7. return exchange.getRequest().getSource();
  8. }

代码示例来源:origin: org.eclipse.californium/californium-core

  1. /**
  2. * Creates a response to the specified request with the specified response
  3. * code. The destination address of the response is the source address of
  4. * the request.
  5. * Type and MID are usually set automatically by the {@link ReliabilityLayer}.
  6. * The token is set automatically by the {@link Matcher}.
  7. *
  8. * @param request
  9. * the request
  10. * @param code
  11. * the code
  12. * @return the response
  13. */
  14. public static Response createResponse(Request request, ResponseCode code) {
  15. Response response = new Response(code);
  16. response.setDestination(request.getSource());
  17. response.setDestinationPort(request.getSourcePort());
  18. return response;
  19. }

代码示例来源:origin: eclipse/californium

  1. /**
  2. * Creates a response to the specified request with the specified response
  3. * code. The destination address of the response is the source address of
  4. * the request.
  5. * Type and MID are usually set automatically by the {@link ReliabilityLayer}.
  6. * The token is set automatically by the {@link Matcher}.
  7. *
  8. * @param request
  9. * the request
  10. * @param code
  11. * the code
  12. * @return the response
  13. */
  14. public static Response createResponse(Request request, ResponseCode code) {
  15. Response response = new Response(code);
  16. response.setDestination(request.getSource());
  17. response.setDestinationPort(request.getSourcePort());
  18. return response;
  19. }

代码示例来源:origin: org.eclipse.californium/californium-core

  1. /**
  2. * Sends the specified response over the same endpoint as the request has
  3. * arrived.
  4. *
  5. * @param response the response
  6. */
  7. public void sendResponse(Response response) {
  8. response.setDestination(request.getSource());
  9. response.setDestinationPort(request.getSourcePort());
  10. setResponse(response);
  11. endpoint.sendResponse(this, response);
  12. }

代码示例来源:origin: org.eclipse.californium/californium-core

  1. @Override
  2. public void deliverRequest(final Exchange exchange) {
  3. Request request = exchange.getRequest();
  4. List<String> path = request.getOptions().getUriPath();
  5. final Resource resource = findResource(path);
  6. if (resource != null) {
  7. checkForObserveOption(exchange, resource);
  8. // Get the executor and let it process the request
  9. Executor executor = resource.getExecutor();
  10. if (executor != null) {
  11. exchange.setCustomExecutor();
  12. executor.execute(new Runnable() {
  13. public void run() {
  14. resource.handleRequest(exchange);
  15. } });
  16. } else {
  17. resource.handleRequest(exchange);
  18. }
  19. } else {
  20. LOGGER.info("Did not find resource " + path.toString() + " requested by " + request.getSource()+":"+request.getSourcePort());
  21. exchange.sendResponse(new Response(ResponseCode.NOT_FOUND));
  22. }
  23. }

代码示例来源:origin: org.eclipse.leshan/leshan-server-cf

  1. objectLinks = LinkObject.parse(request.getPayload());
  2. UpdateRequest updateRequest = new UpdateRequest(registrationId, request.getSource(), request.getSourcePort(),
  3. lifetime, smsNumber, binding, objectLinks);

代码示例来源:origin: org.eclipse.leshan/leshan-server-cf

  1. @Override
  2. public void handleDELETE(CoapExchange exchange) {
  3. LOG.debug("DELETE received : {}", exchange.advanced().getRequest());
  4. List<String> uri = exchange.getRequestOptions().getUriPath();
  5. if (uri != null && uri.size() == 2 && RESOURCE_NAME.equals(uri.get(0))) {
  6. DeregisterRequest deregisterRequest = new DeregisterRequest(uri.get(1));
  7. LwM2mResponse deregisterResponse = registrationHandler.deregister(deregisterRequest);
  8. exchange.respond(fromLwM2mCode(deregisterResponse.getCode()));
  9. if (exchange.advanced().getEndpoint() instanceof SecureEndpoint
  10. && deregisterResponse.getCode().equals(org.eclipse.leshan.ResponseCode.DELETED)) {
  11. // clean the DTLS Session
  12. Request request = exchange.advanced().getRequest();
  13. ((SecureEndpoint) exchange.advanced().getEndpoint()).getDTLSConnector().close(
  14. new InetSocketAddress(request.getSource(), request.getSourcePort()));
  15. }
  16. } else {
  17. LOG.debug("Invalid deregistration");
  18. exchange.respond(ResponseCode.NOT_FOUND);
  19. }
  20. }

代码示例来源:origin: org.github.leshan/leshan-client

  1. final InetSocketAddress source = new InetSocketAddress(request.getSource(), request.getSourcePort());
  2. LOGGER.info("Initiate an observe relation between " + request.getSource() + ":"
  3. + request.getSourcePort() + " and resource " + resource.getURI());
  4. final ObservingEndpoint remote = observeManager.findObservingEndpoint(source);

代码示例来源:origin: org.eclipse.californium/californium-core

  1. if (request.getCode() != Code.GET) return;
  2. InetSocketAddress source = new InetSocketAddress(request.getSource(), request.getSourcePort());
  3. LOGGER.finer("Initiate an observe relation between " + request.getSource() + ":" + request.getSourcePort() + " and resource " + resource.getURI());
  4. ObservingEndpoint remote = observeManager.findObservingEndpoint(source);
  5. ObserveRelation relation = new ObserveRelation(remote, resource, exchange);

代码示例来源:origin: eclipse/californium

  1. InetSocketAddress source = new InetSocketAddress(request.getSource(), request.getSourcePort());
  2. new Object[]{request.getSource(), request.getSourcePort(), resource.getURI()});
  3. ObservingEndpoint remote = observeManager.findObservingEndpoint(source);
  4. ObserveRelation relation = new ObserveRelation(remote, resource, exchange);

代码示例来源:origin: eclipse/californium

  1. return exchange;
  2. } else {
  3. Exchange.KeyUri idByUri = new Exchange.KeyUri(request.getURI(), request.getSource().getAddress(),
  4. request.getSourcePort());
  5. LOGGER.log(Level.FINE, "Looking up ongoing exchange for {0}", idByUri);

代码示例来源:origin: eclipse/californium

  1. private Response responseFor(final Request request) {
  2. Response response = new Response(ResponseCode.CONTENT);
  3. response.setMID(request.getMID());
  4. response.setToken(request.getToken());
  5. response.setBytes(new byte[]{});
  6. response.setSource(request.getDestination());
  7. response.setSourcePort(request.getDestinationPort());
  8. response.setDestination(request.getSource());
  9. response.setDestinationPort(request.getSourcePort());
  10. return response;
  11. }
  12. }

代码示例来源:origin: eclipse/californium

  1. private static Response responseFor(final Request request) {
  2. Response response = new Response(ResponseCode.CONTENT);
  3. response.setMID(request.getMID());
  4. response.setToken(request.getToken());
  5. response.setBytes(new byte[]{});
  6. response.setSource(request.getDestination());
  7. response.setSourcePort(request.getDestinationPort());
  8. response.setDestination(request.getSource());
  9. response.setDestinationPort(request.getSourcePort());
  10. return response;
  11. }
  12. }

相关文章