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

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

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

Request.getTokenString介绍

暂无

代码示例

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

  1. @Override
  2. public void sendRequest(Exchange exchange, final Request request) {
  3. exchange.setObserver(exchangeObserver);
  4. exchangeStore.registerOutboundRequestWithTokenOnly(exchange);
  5. LOGGER.log(Level.FINE, "Tracking open request using {0}", new Object[] { request.getTokenString() });
  6. }

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

  1. /**
  2. * Constructs a new observe relation.
  3. *
  4. * @param endpoint the observing endpoint
  5. * @param resource the observed resource
  6. * @param exchange the exchange that tries to establish the observe relation
  7. */
  8. public ObserveRelation(ObservingEndpoint endpoint, Resource resource, Exchange exchange) {
  9. if (endpoint == null)
  10. throw new NullPointerException();
  11. if (resource == null)
  12. throw new NullPointerException();
  13. if (exchange == null)
  14. throw new NullPointerException();
  15. this.endpoint = endpoint;
  16. this.resource = resource;
  17. this.exchange = exchange;
  18. this.established = false;
  19. this.key = getSource().toString() + "#" + exchange.getRequest().getTokenString();
  20. }

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

  1. /**
  2. * Constructs a new observe relation.
  3. *
  4. * @param endpoint the observing endpoint
  5. * @param resource the observed resource
  6. * @param exchange the exchange that tries to establish the observe relation
  7. */
  8. public ObserveRelation(ObservingEndpoint endpoint, Resource resource, Exchange exchange) {
  9. if (endpoint == null)
  10. throw new NullPointerException();
  11. if (resource == null)
  12. throw new NullPointerException();
  13. if (exchange == null)
  14. throw new NullPointerException();
  15. this.endpoint = endpoint;
  16. this.resource = resource;
  17. this.exchange = exchange;
  18. this.established = false;
  19. this.key = getSource().toString() + "#" + exchange.getRequest().getTokenString();
  20. }

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

  1. @Override
  2. public void sendRequest(final Exchange exchange, final Request request) {
  3. observe(exchange);
  4. exchangeStore.registerOutboundRequest(exchange);
  5. if (LOGGER.isLoggable(Level.FINER)) {
  6. LOGGER.log(
  7. Level.FINER,
  8. "Tracking open request [MID: {0}, Token: {1}]",
  9. new Object[] { request.getMID(), request.getTokenString() });
  10. }
  11. }

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

  1. /**
  2. * Formats a {@link Request} into a readable String representation.
  3. *
  4. * @param r the Request
  5. * @return the pretty print
  6. */
  7. public static String prettyPrint(Request r) {
  8. StringBuilder sb = new StringBuilder();
  9. sb.append("==[ CoAP Request ]=============================================").append(System.lineSeparator());
  10. sb.append(String.format("MID : %d", r.getMID())).append(System.lineSeparator());
  11. sb.append(String.format("Token : %s", r.getTokenString())).append(System.lineSeparator());
  12. sb.append(String.format("Type : %s", r.getType().toString())).append(System.lineSeparator());
  13. sb.append(String.format("Method : %s", r.getCode().toString())).append(System.lineSeparator());
  14. sb.append(String.format("Options: %s", r.getOptions().toString())).append(System.lineSeparator());
  15. sb.append(String.format("Payload: %d Bytes", r.getPayloadSize())).append(System.lineSeparator());
  16. if (r.getPayloadSize() > 0 && MediaTypeRegistry.isPrintable(r.getOptions().getContentFormat())) {
  17. sb.append("---------------------------------------------------------------").append(System.lineSeparator());
  18. sb.append(r.getPayloadString());
  19. sb.append(System.lineSeparator());
  20. }
  21. sb.append("===============================================================");
  22. return sb.toString();
  23. }

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

  1. /**
  2. * Formats a {@link Request} into a readable String representation.
  3. *
  4. * @param r the Request
  5. * @return the pretty print
  6. */
  7. public static String prettyPrint(Request r) {
  8. StringBuilder sb = new StringBuilder();
  9. sb.append("==[ CoAP Request ]=============================================").append(System.lineSeparator());
  10. sb.append(String.format("MID : %d", r.getMID())).append(System.lineSeparator());
  11. sb.append(String.format("Token : %s", r.getTokenString())).append(System.lineSeparator());
  12. sb.append(String.format("Type : %s", r.getType().toString())).append(System.lineSeparator());
  13. sb.append(String.format("Method : %s", r.getCode().toString())).append(System.lineSeparator());
  14. sb.append(String.format("Options: %s", r.getOptions().toString())).append(System.lineSeparator());
  15. sb.append(String.format("Payload: %d Bytes", r.getPayloadSize())).append(System.lineSeparator());
  16. if (r.getPayloadSize() > 0 && MediaTypeRegistry.isPrintable(r.getOptions().getContentFormat())) {
  17. sb.append("---------------------------------------------------------------").append(System.lineSeparator());
  18. sb.append(r.getPayloadString());
  19. sb.append(System.lineSeparator());
  20. }
  21. sb.append("===============================================================");
  22. return sb.toString();
  23. }

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

  1. /**
  2. * Reactive Observe cancellation: Cancel the observe relation by forgetting,
  3. * which will trigger a RST. For TCP, {{@link #proactiveCancel()} will be
  4. * executed.
  5. */
  6. public void reactiveCancel() {
  7. Request request = this.request;
  8. if (CoAP.isTcpScheme(request.getScheme())) {
  9. LOGGER.log(Level.INFO, "Change to cancel the observe {0} proactive over TCP.", request.getTokenString());
  10. proactiveCancel();
  11. } else {
  12. // cancel old ongoing request
  13. cancel();
  14. }
  15. }

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

  1. @Override
  2. public void onTimeout() {
  3. ObserveRelation relation = exchange.getRelation();
  4. LOGGER.log(
  5. Level.INFO,
  6. "Notification for token [{0}] timed out. Canceling all relations with source [{1}]",
  7. new Object[]{ relation.getExchange().getRequest().getTokenString(), relation.getSource() });
  8. relation.cancelAll();
  9. }

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

  1. @Override
  2. public String toString() {
  3. String payload = getPayloadTracingString();
  4. return String.format("%s-%-6s MID=%5d, Token=%s, OptionSet=%s, %s", getType(), getCode(), getMID(), getTokenString(), getOptions(), payload);
  5. }

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

  1. @Override
  2. public String toString() {
  3. String payload = getPayloadTracingString();
  4. return String.format("%s-%-6s MID=%5d, Token=%s, OptionSet=%s, %s", getType(), getCode(), getMID(), getTokenString(), getOptions(), payload);
  5. }

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

  1. @Override
  2. public void onTimeout() {
  3. ObserveRelation relation = exchange.getRelation();
  4. LOGGER.info("Notification " + relation.getExchange().getRequest().getTokenString() + " timed out. Cancel all relations with source " + relation.getSource());
  5. relation.cancelAll();
  6. }

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

  1. @Override
  2. public void onCancel() {
  3. if (!exchange.isComplete()) {
  4. LOGGER.log(Level.FINE, "completing canceled request [MID={0}, token={1}]",
  5. new Object[]{ exchange.getRequest().getMID(), exchange.getRequest().getTokenString() });
  6. exchange.setComplete();
  7. }
  8. }
  9. }

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

  1. public CoapMessage(Request request, boolean incoming) {
  2. this(incoming, request.getType(), request.getMID(), request.getTokenString(), request.getOptions(), request
  3. .getPayload());
  4. this.code = request.getCode().toString();
  5. }

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

  1. payload.append(request.getTokenString());

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

  1. protected final void appendRequestDetails(final Request request) {
  2. if (request.isCanceled()) {
  3. buffer.append("CANCELED ");
  4. }
  5. buffer.append(request.getType()).append(" [MID=").append(request.getMID())
  6. .append(", T=").append(request.getTokenString()).append("], ")
  7. .append(request.getCode()).append(", /").append(request.getOptions().getUriPathString());
  8. appendBlockOption(1, request.getOptions().getBlock1());
  9. appendBlockOption(2, request.getOptions().getBlock2());
  10. appendObserveOption(request.getOptions());
  11. appendSize1(request.getOptions());
  12. appendEtags(request.getOptions());
  13. }

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

  1. Request request = this.request;
  2. if (request.isCanceled()) {
  3. throw new IllegalStateException("observe request already canceled! token " + request.getTokenString());

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

  1. Request request = this.request;
  2. if (request.isCanceled()) {
  3. throw new IllegalStateException("observe request already canceled! token " + request.getTokenString());

相关文章