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

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

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

Request.newPost介绍

[英]Convenience factory method to construct a POST request and equivalent to new Request(Code.POST);
[中]构造POST请求的便利工厂方法,相当于new Request(Code.POST);

代码示例

代码示例来源:origin: org.opendaylight.iotdm/onem2mbenchmark-impl

public OdlOnem2mCoapRequestPrimitiveBuilder setOperationCreate() {
  onem2mRequest.coapRequest = Request.newPost();
  return this;
}
public OdlOnem2mCoapRequestPrimitiveBuilder setOperationRetrieve() {

代码示例来源:origin: org.opendaylight.iotdm/onem2m-protocol-coap

@Override
public void sendNotification(String url, String payload) {
  Request request = Request.newPost();
  request.setURI(url);
  request.setPayload(payload);
  request.send();
  LOG.debug("CoAP: Send notification uri: {}, payload: {}:", url, payload);
}

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

public CC04(String serverURI) {
  super(CC04.class.getSimpleName());
  // create the request
  Request request = Request.newPost();
  // add payload
  request.setPayload("TD_COAP_CORE_04");
  request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  // set the parameters and execute the request
  executeRequest(request, serverURI, RESOURCE_URI);
}

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

public CB04(String serverURI) {
  super(CB04.class.getSimpleName());
  Request request = Request.newPost();
  request.setPayload(data);
  request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  // set the parameters and execute the request
  executeRequest(request, serverURI, "/large-create");
  // TODO: verify resource creation (optional): send GET request to
  // location path of response
}

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

public CB05(String serverURI) {
  super(CB05.class.getSimpleName());
  Request request = Request.newPost();
  request.setPayload(data);
  request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
  // set the parameters and execute the request
  executeRequest(request, serverURI, "/large-post");
}

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

/**
 * Sends a POST request with the specified payload and the specified content
 * format and invokes the specified handler when a response arrives.
 * 
 * @param handler the Response handler
 * @param payload the payload
 * @param format the Content-Format
 */
public void post(CoapHandler handler, String payload, int format) {
  asynchronous(format(Request.newPost().setURI(uri).setPayload(payload), format), handler);
}

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

@Override
public void visit(ExecuteRequest request) {
  coapRequest = Request.newPost();
  setTarget(coapRequest, request.getPath());
  coapRequest.setPayload(request.getParameters());
}

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

/**
 * Sends a POST request with the specified payload and the specified content
 * format and invokes the specified handler when a response arrives.
 * 
 * @param handler the Response handler
 * @param payload the payload
 * @param format the Content-Format
 */
public void post(CoapHandler handler, byte[] payload, int format) {
  asynchronous(format(Request.newPost().setURI(uri).setPayload(payload), format), handler);
}

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

/**
 * Sends a POST request with the specified payload, the specified content
 * format and accept and invokes the specified handler when a response
 * arrives.
 * 
 * @param handler the Response handler
 * @param payload the payload
 * @param format the Content-Format
 * @param accept the Accept option
 */
public void post(CoapHandler handler, String payload, int format, int accept) {
  asynchronous(accept(format(Request.newPost().setURI(uri).setPayload(payload), format), accept), handler);
}

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

/**
 * Sends a POST request with the specified payload, the specified content
 * format and accept and invokes the specified handler when a response
 * arrives.
 * 
 * @param handler the Response handler
 * @param payload the payload
 * @param format the Content-Format
 * @param accept the Accept option
 */
public void post(CoapHandler handler, byte[] payload, int format, int accept) {
  asynchronous(accept(format(Request.newPost().setURI(uri).setPayload(payload), format), accept), handler);
}

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

@Override
public void visit(final BootstrapRequest request) {
  coapRequest = Request.newPost();
  buildRequestSettings(request);
  coapRequest.getOptions().addUriPath("bs");
  coapRequest.getOptions().addUriQuery("ep=" + request.getClientEndpointIdentifier());
  parametersValid = true;
}

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

@Override
public void visit(final BootstrapRequest request) {
  coapRequest = Request.newPost();
  buildRequestSettings(request);
  coapRequest.getOptions().addUriPath("bs");
  coapRequest.getOptions().addUriQuery("ep=" + request.getClientEndpointIdentifier());
  parametersValid = true;
}

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

@Override
public void visit(BootstrapRequest request) {
  coapRequest = Request.newPost();
  buildRequestSettings();
  coapRequest.getOptions().addUriPath("bs");
  coapRequest.getOptions().addUriQuery("ep=" + request.getEndpointName());
}

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

@Override
public void visit(final RegisterRequest request) {
  if (!areParametersValid(request.getClientParameters())) {
    return;
  }
  coapRequest = Request.newPost();
  buildRequestSettings(request);
  coapRequest.getOptions().addUriPath("rd");
  coapRequest.getOptions().addUriQuery("ep=" + request.getClientEndpointIdentifier());
  buildRequestContent(request);
  parametersValid = true;
}

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

@Override
public void visit(ExecuteRequest request) {
  coapRequest = Request.newPost();
  setTarget(coapRequest, destination, request.getPath());
  coapRequest.setPayload(request.getParameters());
  if (request.getContentFormat() != null) {
    coapRequest.getOptions().setContentFormat(request.getContentFormat().getCode());
  }
}

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

@Override
public void visit(final RegisterRequest request) {
  if (!areParametersValid(request.getClientParameters())) {
    return;
  }
  coapRequest = Request.newPost();
  buildRequestSettings(request);
  coapRequest.getOptions().addUriPath("rd");
  coapRequest.getOptions().addUriQuery("ep=" + request.getClientEndpointIdentifier());
  buildRequestContent(request);
  parametersValid = true;
}

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

@Override
public void visit(WriteRequest request) {
  coapRequest = request.isReplaceRequest() ? Request.newPut() : Request.newPost();
  ContentFormat format = request.getContentFormat();
  coapRequest.getOptions().setContentFormat(format.getCode());
  coapRequest.setPayload(encoder.encode(request.getNode(), format, request.getPath(), model));
  setTarget(coapRequest, request.getPath());
}

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

@Override
public void visit(CreateRequest request) {
  coapRequest = Request.newPost();
  coapRequest.getOptions().setContentFormat(request.getContentFormat().getCode());
  coapRequest.setPayload(LwM2mNodeEncoder.encode(request.getObjectInstance(), request.getContentFormat(),
      request.getPath()));
  setTarget(coapRequest, destination, request.getPath());
}

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

@Override
public void visit(WriteRequest request) {
  coapRequest = request.isReplaceRequest() ? Request.newPut() : Request.newPost();
  coapRequest.getOptions().setContentFormat(request.getContentFormat().getCode());
  coapRequest
      .setPayload(LwM2mNodeEncoder.encode(request.getNode(), request.getContentFormat(), request.getPath()));
  setTarget(coapRequest, destination, request.getPath());
}

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

@Override
public void visit(CreateRequest request) {
  coapRequest = Request.newPost();
  coapRequest.getOptions().setContentFormat(request.getContentFormat().getCode());
  // if no instance id, the client will assign it.
  int instanceId = request.getInstanceId() != null ? request.getInstanceId() : LwM2mObjectInstance.UNDEFINED;
  coapRequest.setPayload(encoder.encode(new LwM2mObjectInstance(instanceId, request.getResources()),
      request.getContentFormat(), request.getPath(), model));
  setTarget(coapRequest, request.getPath());
}

相关文章