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

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

本文整理了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

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

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

@Test
public void testRegisterOutboundRequestRejectsOtherRequestWithAlreadyUsedMid() {
  Exchange exchange = newOutboundRequest();
  store.registerOutboundRequest(exchange);
  // WHEN registering another request with the same MID
  Exchange newExchange = newOutboundRequest();
  newExchange.getCurrentRequest().setMID(exchange.getCurrentRequest().getMID());
  try {
    store.registerOutboundRequest(newExchange);
    fail("should have thrown IllegalArgumentException");
  } catch (IllegalArgumentException e) {
    // THEN the newExchange is not put to the store
    KeyMID key = KeyMID.fromOutboundMessage(exchange.getCurrentRequest());
    Exchange exchangeFromStore = store.get(key);
    assertThat(exchangeFromStore, is(exchange));
    assertThat(exchangeFromStore, is(not(newExchange)));
  }
}

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

@Test public void testRequestParsing() {
    Request request = new Request(Code.POST);
    request.setType(Type.NON);
    request.setMID(expectedMid);
    request.setToken(new byte[] { 11, 82, -91, 77, 3 });
    request.getOptions().addIfMatch(new byte[] { 34, -17 }).addIfMatch(new byte[] { 88, 12, -2, -99, 5 })
        .setContentFormat(40).setAccept(40);

    RawData rawData = serializer.serializeRequest(request);
//        MessageHeader header = parser.parseHeader(rawData);
//        assertTrue(CoAP.isRequest(header.getCode()));
//
//        Request result = parser.parseRequest(rawData);
    Request result = (Request) parser.parseMessage(rawData);
    assertEquals(request.getMID(), result.getMID());
    assertArrayEquals(request.getToken(), result.getToken());
    assertEquals(request.getOptions().asSortedList(), result.getOptions().asSortedList());
  }

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

request.setMID(1234);
client.sendRequest(request);
request.setMID(4711);
client.sendRequest(request);

相关文章