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

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

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

Request.setDestinationPort介绍

暂无

代码示例

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

private void buildRequestSettings(final AbstractLwM2mClientRequest request) {
  timeout = request.getTimeout();
  coapRequest.setDestination(serverAddress.getAddress());
  coapRequest.setDestinationPort(serverAddress.getPort());
}

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

private void buildRequestSettings(final AbstractLwM2mClientRequest request) {
  timeout = request.getTimeout();
  coapRequest.setDestination(serverAddress.getAddress());
  coapRequest.setDestinationPort(serverAddress.getPort());
}

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

setDestinationPort(port);

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

@Test
public void testSendRequestAddsMessageCallbackToOutboundMessage() throws Exception {
  // GIVEN an outbound request
  latch = new CountDownLatch(1);
  Request request = Request.newGet();
  request.setDestination(InetAddress.getLoopbackAddress());
  request.setDestinationPort(CoAP.DEFAULT_COAP_PORT);
  // WHEN sending the request to the peer
  endpoint.sendRequest(request);
  // THEN assert that the message delivered to the Connector contains a
  // MessageCallback
  assertTrue(latch.await(1, TimeUnit.SECONDS));
}

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

@Override
  public void go() {
    Request request = new Request(code);
    if (destination != null) {
      request.setDestination(destination.getAddress());
      request.setDestinationPort(destination.getPort());
    }
    setProperties(request);
    RawData raw = serializer.serializeRequest(request);
    send(raw);
  }
}

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

postSecurity.setConfirmable(true);
postSecurity.setDestination(targetAddress);
postSecurity.setDestinationPort(targetPort);
postSecurity.setPayload(encoded.array());

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

private static Exchange sendObserveRequest(final UdpMatcher matcher) {
  Request request = Request.newGet();
  request.setDestination(dest.getAddress());
  request.setDestinationPort(dest.getPort());
  request.setObserve();
  Exchange exchange = new Exchange(request, Origin.LOCAL);
  matcher.sendRequest(exchange, request);
  return exchange;
}

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

postServer.setConfirmable(true);
postServer.setDestination(targetAddress);
postServer.setDestinationPort(targetPort);
postServer.setPayload(encoded.array());
postServer.send(e).addMessageObserver(new MessageObserver() {

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

private static Exchange sendRequest(final UdpMatcher matcher, final CorrelationContext ctx) {
  Request request = Request.newGet();
  request.setDestination(dest.getAddress());
  request.setDestinationPort(dest.getPort());
  Exchange exchange = new Exchange(request, Origin.LOCAL);
  exchange.setRequest(request);
  matcher.sendRequest(exchange, request);
  exchange.setCorrelationContext(ctx);
  return exchange;
}

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

private Exchange sendRequest(final TcpMatcher matcher, final CorrelationContext ctx) {
  Request request = Request.newGet();
  request.setDestination(dest.getAddress());
  request.setDestinationPort(dest.getPort());
  Exchange exchange = new Exchange(request, Origin.LOCAL);
  exchange.setRequest(request);
  matcher.sendRequest(exchange, request);
  exchange.setCorrelationContext(ctx);
  return exchange;
}

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

Request refresh = Request.newGet();
refresh.setDestination(request.getDestination());
refresh.setDestinationPort(request.getDestinationPort());

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

private final void setTarget(Request coapRequest, Client client, LwM2mPath path) {
  coapRequest.setDestination(client.getAddress());
  coapRequest.setDestinationPort(client.getPort());
  // root path
  if (client.getRootPath() != null) {
    for (String rootPath : client.getRootPath().split("/")) {
      if (!StringUtils.isEmpty(rootPath)) {
        coapRequest.getOptions().addUriPath(rootPath);
      }
    }
  }
  // objectId
  coapRequest.getOptions().addUriPath(Integer.toString(path.getObjectId()));
  // objectInstanceId
  if (path.getObjectInstanceId() == null) {
    if (path.getResourceId() != null) {
      coapRequest.getOptions().addUriPath("0"); // default instanceId
    }
  } else {
    coapRequest.getOptions().addUriPath(Integer.toString(path.getObjectInstanceId()));
  }
  // resourceId
  if (path.getResourceId() != null) {
    coapRequest.getOptions().addUriPath(Integer.toString(path.getResourceId()));
  }
}

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

Request refresh = Request.newGet();
refresh.setDestination(request.getDestination());
refresh.setDestinationPort(request.getDestinationPort());

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

@Test
public void testNonconfirmable() throws Exception {
  createSimpleServer();
  // send request
  Request request = new Request(CoAP.Code.POST);
  request.setConfirmable(false);
  request.setDestination(InetAddress.getLoopbackAddress());
  request.setDestinationPort(serverPort);
  request.setPayload("client says hi");
  request.send();
  System.out.println("client sent request");
  // receive response and check
  Response response = request.waitForResponse(1000);
  assertNotNull("Client received no response", response);
  System.out.println("client received response");
  assertEquals(response.getPayloadString(), SERVER_RESPONSE);
}

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

/**
 * Send request with option "cancel observe" (GET with Observe=1).
 */
private void sendCancelObserve() {
  Request request = this.request;
  Request cancel = Request.newGet();
  cancel.setDestination(request.getDestination());
  cancel.setDestinationPort(request.getDestinationPort());
  // use same Token
  cancel.setToken(request.getToken());
  // copy options, but set Observe to cancel
  cancel.setOptions(request.getOptions());
  cancel.setObserveCancel();
  // dispatch final response to the same message observers
  for (MessageObserver mo : request.getMessageObservers()) {
    cancel.addMessageObserver(mo);
  }
  endpoint.sendRequest(cancel);
}

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

private static Request getNextRequestBlock(final Request request, final BlockwiseStatus status) {
  int num = status.getCurrentNum();
  int szx = status.getCurrentSzx();
  Request block = new Request(request.getCode());
  // do not enforce CON, since NON could make sense over SMS or similar transports
  block.setType(request.getType());
  block.setDestination(request.getDestination());
  block.setDestinationPort(request.getDestinationPort());
  // copy options
  block.setOptions(new OptionSet(request.getOptions()));
  // copy message observers so that a failing blockwise request also notifies observers registered with
  // the original request
  block.addMessageObservers(request.getMessageObservers());
  int currentSize = 1 << (4 + szx);
  int from = num * currentSize;
  int to = Math.min((num + 1) * currentSize, request.getPayloadSize());
  int length = to - from;
  byte[] blockPayload = new byte[length];
  System.arraycopy(request.getPayload(), from, blockPayload, 0, length);
  block.setPayload(blockPayload);
  boolean m = (to < request.getPayloadSize());
  block.getOptions().setBlock1(szx, m, num);
  status.setComplete(!m);
  return block;
}

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

/**
 * Verifies that canceling a message that has no MID set does not throw an exception.
 * 
 */
@Test
public void testExchangeObserverToleratesUnsentMessages() {
  // GIVEN a request that has no MID and has not been sent yet
  UdpMatcher matcher = newMatcher(false);
  Request request = Request.newGet();
  request.setDestination(dest.getAddress());
  request.setDestinationPort(dest.getPort());
  Exchange exchange = new Exchange(request, Origin.LOCAL);
  exchange.setRequest(request);
  assertFalse(request.hasMID());
  matcher.observe(exchange);
  // WHEN the request is canceled and thus the message exchange completes
  exchange.setComplete();
  // THEN the matcher's exchange observer does not throw an exception
}

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

/**
 * Send request with option "cancel observe" (GET with Observe=1).
 */
private void sendCancelObserve() {
  Request request = this.request;
  Request cancel = Request.newGet();
  cancel.setDestination(request.getDestination());
  cancel.setDestinationPort(request.getDestinationPort());
  // use same Token
  cancel.setToken(request.getToken());
  // copy options, but set Observe to cancel
  cancel.setOptions(request.getOptions());
  cancel.setObserveCancel();
  
  // dispatch final response to the same message observers
  for (MessageObserver mo: request.getMessageObservers()) {
    cancel.addMessageObserver(mo);
  }
  
  endpoint.sendRequest(cancel);
}

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

private static Request getNextRequestBlock(final Request request, final BlockwiseStatus status) {
  int num = status.getCurrentNum();
  int szx = status.getCurrentSzx();
  Request block = new Request(request.getCode());
  // do not enforce CON, since NON could make sense over SMS or similar transports
  block.setType(request.getType());
  block.setDestination(request.getDestination());
  block.setDestinationPort(request.getDestinationPort());
  // copy options
  block.setOptions(new OptionSet(request.getOptions()));
  // copy message observers so that a failing blockwise request also notifies observers registered with
  // the original request
  block.addMessageObservers(request.getMessageObservers());
  int currentSize = 1 << (4 + szx);
  int from = num * currentSize;
  int to = Math.min((num + 1) * currentSize, request.getPayloadSize());
  int length = to - from;
  byte[] blockPayload = new byte[length];
  System.arraycopy(request.getPayload(), from, blockPayload, 0, length);
  block.setPayload(blockPayload);
  boolean m = (to < request.getPayloadSize());
  block.getOptions().setBlock1(szx, m, num);
  status.setComplete(!m);
  return block;
}

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

deleteAll.setConfirmable(true);
deleteAll.setDestination(exchange.getSourceAddress());
deleteAll.setDestinationPort(exchange.getSourcePort());

相关文章

微信公众号

最新文章

更多