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

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

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

Request.getScheme介绍

[英]Gets the scheme.
[中]得到了这个计划。

代码示例

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

/**
 * Reactive Observe cancellation: Cancel the observe relation by forgetting,
 * which will trigger a RST. For TCP, {{@link #proactiveCancel()} will be
 * executed.
 */
public void reactiveCancel() {
  Request request = this.request;
  if (CoAP.isTcpScheme(request.getScheme())) {
    LOGGER.log(Level.INFO, "Change to cancel the observe {0} proactive over TCP.", request.getTokenString());
    proactiveCancel();
  } else {
    // cancel old ongoing request
    cancel();
  }
}

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

/**
 * Returns the effective endpoint that the specified request is supposed to
 * be sent over. If an endpoint has explicitly been set to this CoapClient,
 * this endpoint will be used. If no endpoint has been set, the client will
 * effectively use a default endpoint of the {@link EndpointManager}.
 * 
 * @param request the request to be sent
 * @return the effective endpoint that the request is going o be sent over.
 */
protected Endpoint getEffectiveEndpoint(Request request) {
  Endpoint myEndpoint = getEndpoint();
  
  // custom endpoint
  if (myEndpoint != null) return myEndpoint;
  
  // default endpoints
  if (CoAP.COAP_SECURE_URI_SCHEME.equals(request.getScheme())) {
    // this is the case when secure coap is supposed to be used
    return EndpointManager.getEndpointManager().getDefaultSecureEndpoint();
  } else if (CoAP.COAP_TCP_URI_SCHEME.equals(request.getScheme())) {
    // Running over TCP.
    return EndpointManager.getEndpointManager().getDefaultTcpEndpoint();
  } else if (CoAP.COAP_SECURE_TCP_URI_SCHEME.equals(request.getScheme())) {
    // Running over TLS.
    return EndpointManager.getEndpointManager().getDefaultSecureTcpEndpoint();
  } else {
    // this is the normal case
    return EndpointManager.getEndpointManager().getDefaultEndpoint();
  }
}

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

request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
if (request.getScheme().equals(CoAP.COAP_SECURE_URI_SCHEME)) {

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

/**
 * Returns the effective endpoint that the specified request is supposed to
 * be sent over. If an endpoint has explicitly been set to this CoapClient,
 * this endpoint will be used. If no endpoint has been set, the client will
 * effectively use a default endpoint of the {@link EndpointManager}.
 * 
 * @param request the request to be sent
 * @return the effective endpoint that the request is going o be sent over.
 */
protected Endpoint getEffectiveEndpoint(Request request) {
  Endpoint myEndpoint = getEndpoint();
  
  // custom endpoint
  if (myEndpoint != null) return myEndpoint;
  
  // default endpoints
  if (CoAP.COAP_SECURE_URI_SCHEME.equals(request.getScheme())) {
    // this is the case when secure coap is supposed to be used
    return EndpointManager.getEndpointManager().getDefaultSecureEndpoint();
  } else {
    // this is the normal case
    return EndpointManager.getEndpointManager().getDefaultEndpoint();
  }
}

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

/**
 * Sends the request over the default endpoint to its destination and
 * expects a response back.
 * @return this request
 */
public Request send() {
  validateBeforeSending();
  if (CoAP.COAP_SECURE_URI_SCHEME.equals(getScheme())) {
    // This is the case when secure coap is supposed to be used
    EndpointManager.getEndpointManager().getDefaultSecureEndpoint().sendRequest(this);
  } else {
    // This is the normal case
    EndpointManager.getEndpointManager().getDefaultEndpoint().sendRequest(this);
  }
  return this;
}

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

if (CoAP.isSupportedScheme(getScheme())) {
    if (CoAP.getDefaultPort(getScheme()) == port) {
      port = -1;
String query = getOptions().getURIQueryCount() > 0 ? getOptions().getUriQueryString() : null;
try {
  URI uri = new URI(getScheme(), null, host, port, path, query, null);

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

if (CoAP.isSupportedScheme(getScheme())) {
    if (CoAP.getDefaultPort(getScheme()) == port) {
      port = -1;
String query = getOptions().getURIQueryCount() > 0 ? getOptions().getUriQueryString() : null;
try {
  URI uri = new URI(getScheme(), null, host, port, path, query, null);

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

/**
 * Sends the request over the default endpoint to its destination and
 * expects a response back.
 * 
 * @return this request
 * @throws NullPointerException if this request has no destination set.
 */
public Request send() {
  validateBeforeSending();
  if (CoAP.COAP_SECURE_URI_SCHEME.equals(getScheme())) {
    // This is the case when secure coap is supposed to be used
    EndpointManager.getEndpointManager().getDefaultSecureEndpoint().sendRequest(this);
  } else {
    // This is the normal case
    EndpointManager.getEndpointManager().getDefaultEndpoint().sendRequest(this);
  }
  return this;
}

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

@Test
public void testStandardSchemeIsSetOnIncomingRequest() throws Exception {
  latch = new CountDownLatch(1);
  RawData inboundRequest = RawData.inbound(getSerializedRequest(), SOURCE_ADDRESS, null, null, false);
  connector.receiveMessage(inboundRequest);
  assertTrue(latch.await(2, TimeUnit.SECONDS));
  assertThat(receivedRequests.get(0).getScheme(), is(CoAP.COAP_URI_SCHEME));
}

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

@Test
public void testSecureSchemeIsSetOnIncomingRequest() throws Exception {
  latch = new CountDownLatch(1);
  CorrelationContext secureCtx = new DtlsCorrelationContext("session", "1", "CIPHER");
  RawData inboundRequest = RawData.inbound(getSerializedRequest(), SOURCE_ADDRESS, null, secureCtx, false);
  connector.receiveMessage(inboundRequest);
  assertTrue(latch.await(2, TimeUnit.SECONDS));
  assertThat(receivedRequests.get(0).getScheme(), is(CoAP.COAP_SECURE_URI_SCHEME));
}

相关文章