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

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

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

Request.setMID介绍

暂无

代码示例

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

  1. request.setMID(currendMID.getAndIncrement() & 0x0000FFFF);

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

  1. @Test
  2. public void testRegisterOutboundRequestRejectsOtherRequestWithAlreadyUsedMid() {
  3. Exchange exchange = newOutboundRequest();
  4. store.registerOutboundRequest(exchange);
  5. // WHEN registering another request with the same MID
  6. Exchange newExchange = newOutboundRequest();
  7. newExchange.getCurrentRequest().setMID(exchange.getCurrentRequest().getMID());
  8. try {
  9. store.registerOutboundRequest(newExchange);
  10. fail("should have thrown IllegalArgumentException");
  11. } catch (IllegalArgumentException e) {
  12. // THEN the newExchange is not put to the store
  13. KeyMID key = KeyMID.fromOutboundMessage(exchange.getCurrentRequest());
  14. Exchange exchangeFromStore = store.get(key);
  15. assertThat(exchangeFromStore, is(exchange));
  16. assertThat(exchangeFromStore, is(not(newExchange)));
  17. }
  18. }

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

  1. @Test public void testRequestParsing() {
  2. Request request = new Request(Code.POST);
  3. request.setType(Type.NON);
  4. request.setMID(expectedMid);
  5. request.setToken(new byte[] { 11, 82, -91, 77, 3 });
  6. request.getOptions().addIfMatch(new byte[] { 34, -17 }).addIfMatch(new byte[] { 88, 12, -2, -99, 5 })
  7. .setContentFormat(40).setAccept(40);
  8. RawData rawData = serializer.serializeRequest(request);
  9. // MessageHeader header = parser.parseHeader(rawData);
  10. // assertTrue(CoAP.isRequest(header.getCode()));
  11. //
  12. // Request result = parser.parseRequest(rawData);
  13. Request result = (Request) parser.parseMessage(rawData);
  14. assertEquals(request.getMID(), result.getMID());
  15. assertArrayEquals(request.getToken(), result.getToken());
  16. assertEquals(request.getOptions().asSortedList(), result.getOptions().asSortedList());
  17. }

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

  1. request.setMID(1234);
  2. client.sendRequest(request);
  3. request.setMID(4711);
  4. client.sendRequest(request);

相关文章