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

x33g5p2x  于2022-01-26 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(48)

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

OptionSet.setMaxAge介绍

[英]Sets the Max-Age option. Returns the current OptionSet object for a fluent API.
[中]设置“最大年龄”选项。返回fluent API的当前OptionSet对象。

代码示例

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

cachedResponse.getOptions().setMaxAge(newMaxAge);
cachedResponse.setTimestamp(newCurrentTime);
response.getOptions().setMaxAge(OptionNumberRegistry.Defaults.MAX_AGE);

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

response.getOptions().setMaxAge(nanosLeft);

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

cachedResponse.getOptions().setMaxAge(newMaxAge);
cachedResponse.setTimestamp(newCurrentTime);
response.getOptions().setMaxAge(OptionNumberRegistry.Defaults.MAX_AGE);

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

response.getOptions().setMaxAge(nanosLeft);

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

coapResponse.getOptions().setMaxAge(OptionNumberRegistry.Defaults.MAX_AGE);
} else {
  coapResponse.getOptions().setMaxAge(0);

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

coapResponse.getOptions().setMaxAge(OptionNumberRegistry.Defaults.MAX_AGE);
} else {
  coapResponse.getOptions().setMaxAge(0);

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

/**
 * Respond with the specified response.
 * @param response the response
 */
public void respond(Response response) {
  if (response == null) throw new NullPointerException();
  
  // set the response options configured through the CoapExchange API
  if (locationPath != null) response.getOptions().setLocationPath(locationPath);
  if (locationQuery != null) response.getOptions().setLocationQuery(locationQuery);
  if (maxAge != 60) response.getOptions().setMaxAge(maxAge);
  if (eTag != null) {
    response.getOptions().clearETags();
    response.getOptions().addETag(eTag);
  }
  
  resource.checkObserveRelation(exchange, response);
  
  exchange.sendResponse(response);
}

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

/**
 * Respond with the specified response.
 * @param response the response
 */
public void respond(Response response) {
  if (response == null) throw new NullPointerException();
  
  // set the response options configured through the CoapExchange API
  if (locationPath != null) response.getOptions().setLocationPath(locationPath);
  if (locationQuery != null) response.getOptions().setLocationQuery(locationQuery);
  if (maxAge != 60) response.getOptions().setMaxAge(maxAge);
  if (eTag != null) {
    response.getOptions().clearETags();
    response.getOptions().addETag(eTag);
  }
  
  resource.checkObserveRelation(exchange, response);
  
  exchange.sendResponse(response);
}

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

@Test
  public void testToString() {
    OptionSet options = new OptionSet();
    options.addETag(new byte[] {1, 2, 3});
    options.addETag(new byte[] {(byte)0xBE, (byte)0xEF});
    options.addLocationPath("abc");
    options.setUriPath("/this/is/a/test");
    
    Assert.assertEquals("{\"ETag\":[0x010203,0xbeef], \"Location-Path\":\"abc\", \"Uri-Path\":[\"this\",\"is\",\"a\",\"test\"]}", options.toString());

    options.setMaxAge(77);
    
    Assert.assertEquals("{\"ETag\":[0x010203,0xbeef], \"Location-Path\":\"abc\", \"Uri-Path\":[\"this\",\"is\",\"a\",\"test\"], \"Max-Age\":77}", options.toString());
  }
}

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

case OptionNumberRegistry.URI_PATH:       addUriPath(option.getStringValue()); break;
case OptionNumberRegistry.CONTENT_FORMAT: setContentFormat(option.getIntegerValue()); break;
case OptionNumberRegistry.MAX_AGE:        setMaxAge(option.getLongValue()); break;
case OptionNumberRegistry.URI_QUERY:      addUriQuery(option.getStringValue()); break;
case OptionNumberRegistry.ACCEPT:         setAccept(option.getIntegerValue()); break;

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

case OptionNumberRegistry.URI_PATH:       addUriPath(option.getStringValue()); break;
case OptionNumberRegistry.CONTENT_FORMAT: setContentFormat(option.getIntegerValue()); break;
case OptionNumberRegistry.MAX_AGE:        setMaxAge(option.getLongValue()); break;
case OptionNumberRegistry.URI_QUERY:      addUriQuery(option.getStringValue()); break;
case OptionNumberRegistry.ACCEPT:         setAccept(option.getIntegerValue()); break;

相关文章

微信公众号

最新文章

更多