本文整理了Java中org.eclipse.californium.core.coap.Request.setObserveCancel
方法的一些代码示例,展示了Request.setObserveCancel
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.setObserveCancel
方法的具体详情如下:
包路径:org.eclipse.californium.core.coap.Request
类名称:Request
方法名:setObserveCancel
[英]Sets CoAP's observe option to the value of 1 to proactively cancel.
[中]将CoAP的“观察”选项设置为1,以便主动取消。
代码示例来源:origin: eclipse/californium
/**
* Verifies that only GET requests can be marked for canceling an observe relation.
*/
@Test
public void setObserveCancelFailsForNonGetRequest() {
Code[] illegalCodes = new Code[]{ Code.DELETE, Code.POST, Code.PUT };
for (Code code : illegalCodes) {
try {
Request req = new Request(code);
req.setObserveCancel();
fail("should not be able to set observe option on " + code + " request");
} catch (IllegalStateException e) {
// as expected
}
}
}
代码示例来源:origin: eclipse/californium
deregister.setURI(uri);
deregister.setToken(request.getToken());
deregister.setObserveCancel();
request = deregister;
request.send();
代码示例来源: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: 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);
}
内容来源于网络,如有侵权,请联系作者删除!