本文整理了Java中org.eclipse.californium.core.coap.Request.send
方法的一些代码示例,展示了Request.send
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.send
方法的具体详情如下:
包路径:org.eclipse.californium.core.coap.Request
类名称:Request
方法名:send
[英]Sends the request over the default endpoint to its destination and expects a response back.
[中]通过默认端点将请求发送到其目标,并期望得到响应。
代码示例来源:origin: eclipse/californium
public static void selfTest() {
try {
Request request = Request.newGet();
request.setURI("localhost:5683/benchmark");
request.send();
Response response = request.waitForResponse(1000);
System.out.println("received "+response);
} catch (Exception e) {
e.printStackTrace();
}
}
}
代码示例来源: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
request.send();
if (sync) {
request.waitForResponse(5000);
代码示例来源:origin: eclipse/californium
private static boolean ping(String address) {
try {
Request request = new Request(null);
request.setType(Type.CON);
request.setToken(new byte[0]);
request.setURI(address);
System.out.println("++++++ Sending Ping ++++++");
request.send().waitForResponse(5000);
return request.isRejected();
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
代码示例来源:origin: eclipse/californium
boolean success = true;
request.send();
代码示例来源:origin: eclipse/californium
outgoingRequest.send();
代码示例来源:origin: org.eclipse.californium/californium-proxy
outgoingRequest.send();
代码示例来源:origin: eclipse/californium
request.send();
response = request.waitForResponse(6000);
request.send();
response = request.waitForResponse(6000);
代码示例来源:origin: org.eclipse.leshan/leshan-server-cf
postSecurity.setPayload(encoded.array());
postSecurity.send(e).addMessageObserver(new MessageObserver() {
代码示例来源:origin: org.eclipse.leshan/leshan-server-cf
postServer.setDestinationPort(targetPort);
postServer.setPayload(encoded.array());
postServer.send(e).addMessageObserver(new MessageObserver() {
@Override
public void onTimeout() {
代码示例来源:origin: eclipse/californium
private void sendRequestAndExpect(String expected) throws Exception {
System.out.println();
Thread.sleep(100);
Request request = Request.newGet();
request.setURI("localhost:"+serverPort+"/res");
String response = request.send().waitForResponse(1000).getPayloadString();
Assert.assertEquals(expected, response);
}
代码示例来源:origin: org.opendaylight.iotdm/onem2m-protocol-coap
coapRequest.send();
Response coapResponse = coapRequest.waitForResponse();
if (null == coapResponse) {
代码示例来源:origin: eclipse/californium
/**
* Verifies that the server cleans up all exchanges after serving a NON GET.
*
* @throws Exception if the test fails.
*/
@Test
public void testSimpleNONGet() throws Exception {
String uri = uriOf(URI);
LOGGER.log(Level.FINE, "Test simple NON GET to {0}", uri);
String currentResponseText = "simple NON GET";
resource.setResponse(currentResponseText, Mode.PIGGY_BACKED_RESPONSE);
Request request = Request.newGet();
request.setURI(uri);
request.setType(Type.NON);
Response response = request.send(clientEndpoint).waitForResponse(ACK_TIMEOUT);
assertThat("Client did not receive response to NON request in time", response, is(notNullValue()));
LOGGER.log(Level.FINE, "Client received response [{0}] with msg type [{1}]", new Object[]{response.getPayloadString(), response.getType()});
assertThat(response.getPayloadString(), is(currentResponseText));
assertThat(response.getType(), is(Type.NON));
}
代码示例来源: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
String resp1 = Request.newGet().setURI(base+NAME_1).send().waitForResponse(1000).getPayloadString();
Assert.assertEquals(PAYLOAD, resp1);
String resp2 = Request.newGet().setURI(base+NAME_1+"/"+CHILD).send().waitForResponse(1000).getPayloadString();
Assert.assertEquals(CHILD_PAYLOAD, resp2);
String resp3 = Request.newGet().setURI(base+NAME_2).send().waitForResponse(1000).getPayloadString();
Assert.assertEquals(PAYLOAD, resp3);
String resp4 = Request.newGet().setURI(base+NAME_2+"/"+CHILD).send().waitForResponse(1000).getPayloadString();
Assert.assertEquals(CHILD_PAYLOAD, resp4);
ResponseCode code1 = Request.newGet().setURI(base+NAME_1).send().waitForResponse(1000).getCode();
Assert.assertEquals(ResponseCode.NOT_FOUND, code1);
ResponseCode code2 = Request.newGet().setURI(base+NAME_1+"/"+CHILD).send().waitForResponse(1000).getCode();
Assert.assertEquals(ResponseCode.NOT_FOUND, code2);
代码示例来源:origin: org.eclipse.leshan/leshan-server-cf
deleteAll.setDestinationPort(exchange.getSourcePort());
deleteAll.send(e).addMessageObserver(new MessageObserver() {
代码示例来源:origin: eclipse/californium
@Test
public void testConfirmable() throws Exception {
// send request
Request req2acc = new Request(Code.POST);
req2acc.setConfirmable(true);
req2acc.setURI(getUri(ACC_RESOURCE));
req2acc.setPayload("client says hi");
req2acc.send();
// receive response and check
Response response = req2acc.waitForResponse(1000);
assertPayloadIsOfCorrectType(response, SERVER_RESPONSE, Type.CON);
Request req2noacc = new Request(Code.POST);
req2noacc.setConfirmable(true);
req2noacc.setURI(getUri(NO_ACC_RESOURCE));
req2noacc.setPayload("client says hi");
req2noacc.send();
// receive response and check
response = req2noacc.waitForResponse(1000);
assertPayloadIsOfCorrectType(response, SERVER_RESPONSE, Type.ACK);
}
代码示例来源:origin: eclipse/californium
@Test
public void testNonConfirmable() throws Exception {
// send request
Request req2acc = new Request(Code.POST);
req2acc.setConfirmable(false);
req2acc.setURI(getUri(ACC_RESOURCE));
req2acc.setPayload("client says hi");
req2acc.send();
// receive response and check
Response response = req2acc.waitForResponse(1000);
assertPayloadIsOfCorrectType(response, SERVER_RESPONSE, Type.NON);
Request req2noacc = new Request(Code.POST);
req2noacc.setConfirmable(false);
req2noacc.setURI(getUri(NO_ACC_RESOURCE));
req2noacc.setPayload("client says hi");
req2noacc.send();
// receive response and check
response = req2noacc.waitForResponse(1000);
assertPayloadIsOfCorrectType(response, SERVER_RESPONSE, Type.NON);
}
代码示例来源:origin: eclipse/californium
requestA.setURI(uriX);
requestA.setObserve();
requestA.send();
requestB.send();
代码示例来源:origin: eclipse/californium
request.getOptions().setBlock2(szx, false, num);
Response response = request.send().waitForResponse(1000);
Assert.assertNotNull("Client received no response", response);
Assert.assertEquals(expectations[i], response.getPayloadString());
内容来源于网络,如有侵权,请联系作者删除!