本文整理了Java中org.eclipse.californium.core.coap.Request.setObserve
方法的一些代码示例,展示了Request.setObserve
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.setObserve
方法的具体详情如下:
包路径:org.eclipse.californium.core.coap.Request
类名称:Request
方法名:setObserve
[英]Sets CoAP's observe option. If the target resource of this request responds with a success code and also sets the observe option, it will send more responses in the future whenever the resource's state changes.
[中]设置CoAP的观察选项。如果此请求的目标资源使用成功代码进行响应,并且还设置了“观察”选项,则将来每当资源的状态发生变化时,它将发送更多响应。
代码示例来源:origin: eclipse/californium
public CO06(String serverURI) {
super(CO06.class.getSimpleName());
// create the request
Request request = new Request(Code.GET, Type.CON);
// set Observe option
request.setObserve();
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public CO04(String serverURI) {
super(CO04.class.getSimpleName());
// create the request
Request request = new Request(Code.GET, Type.CON);
// set Observe option
request.setObserve();
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public CO09(String serverURI) {
super(CO09.class.getSimpleName());
// create the request
Request request = new Request(Code.GET, Type.CON);
// request.setToken(TokenManager.getInstance().acquireToken(false));
request.setObserve();
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public CO02_05(String serverURI) {
super(CO02_05.class.getSimpleName());
// create the request
Request request = new Request(Code.GET, Type.NON);
// set Observe option
request.setObserve();
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public CO07(String serverURI) {
super(CO07.class.getSimpleName());
// create the request
Request request = new Request(Code.GET, Type.CON);
// request.setToken(TokenManager.getInstance().acquireToken());
request.setObserve();
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public CO08(String serverURI) {
super(CO08.class.getSimpleName());
// create the request
Request request = new Request(Code.GET, Type.CON);
// request.setToken(TokenManager.getInstance().acquireToken(false));
request.setObserve();
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public CO01_12(String serverURI) {
super(CO01_12.class.getSimpleName());
// create the request
Request request = new Request(Code.GET, Type.CON);
// set Observe option
request.setObserve();
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
public CO10(String serverURI) {
super(CO10.class.getSimpleName());
// create the request
Request request = new Request(Code.GET, Type.CON);
// set Observe option
request.setObserve();
// set the parameters and execute the request
executeRequest(request, serverURI, RESOURCE_URI);
}
代码示例来源:origin: eclipse/californium
/**
* Sends an observe request and waits until it has been established
* whereupon the specified handler is invoked when a notification arrives.
*
* @param handler the Response handler
* @return the CoAP observe relation
*/
public CoapObserveRelation observeAndWait(CoapHandler handler) {
Request request = newGet().setURI(uri).setObserve();
return observeAndWait(request, handler);
}
代码示例来源:origin: org.eclipse.californium/californium-core
/**
* Sends an observe request and waits until it has been established
* whereupon the specified handler is invoked when a notification arrives.
*
* @param handler the Response handler
* @return the CoAP observe relation
*/
public CoapObserveRelation observeAndWait(CoapHandler handler) {
Request request = Request.newGet().setURI(uri).setObserve();
return observeAndWait(request, handler);
}
代码示例来源:origin: eclipse/californium
/**
* Sends an observe request and invokes the specified handler each time
* a notification arrives.
*
* @param handler the Response handler
* @return the CoAP observe relation
*/
public CoapObserveRelation observe(CoapHandler handler) {
Request request = newGet().setURI(uri).setObserve();
return observe(request, handler);
}
代码示例来源:origin: org.eclipse.californium/californium-core
/**
* Sends an observe request and invokes the specified handler each time
* a notification arrives.
*
* @param handler the Response handler
* @return the CoAP observe relation
*/
public CoapObserveRelation observe(CoapHandler handler) {
Request request = Request.newGet().setURI(uri).setObserve();
return observe(request, handler);
}
代码示例来源:origin: org.eclipse.leshan/leshan-server-cf
@Override
public void visit(ObserveRequest request) {
coapRequest = Request.newGet();
coapRequest.setObserve();
setTarget(coapRequest, destination, request.getPath());
}
代码示例来源:origin: eclipse/californium
/**
* Sends an observe request with the specified Accept option and invokes the
* specified handler each time a notification arrives.
*
* @param handler the Response handler
* @param accept the Accept option
* @return the CoAP observe relation
*/
public CoapObserveRelation observe(CoapHandler handler, int accept) {
Request request = newGet().setURI(uri).setObserve();
return observe(accept(request, accept), handler);
}
代码示例来源:origin: org.eclipse.californium/californium-core
/**
* Sends an observe request with the specified Accept option and invokes the
* specified handler each time a notification arrives.
*
* @param handler the Response handler
* @param accept the Accept option
* @return the CoAP observe relation
*/
public CoapObserveRelation observe(CoapHandler handler, int accept) {
Request request = Request.newGet().setURI(uri).setObserve();
return observe(accept(request, accept), handler);
}
代码示例来源:origin: eclipse/californium
/**
* Sends an observe request with the specified Accept option and waits until
* it has been established whereupon the specified handler is invoked when a
* notification arrives.
*
* @param handler the Response handler
* @param accept the Accept option
* @return the CoAP observe relation
*/
public CoapObserveRelation observeAndWait(CoapHandler handler, int accept) {
Request request = newGet().setURI(uri).setObserve();
request.getOptions().setAccept(accept);
return observeAndWait(request, handler);
}
代码示例来源:origin: org.eclipse.californium/californium-core
/**
* Sends an observe request with the specified Accept option and waits until
* it has been established whereupon the specified handler is invoked when a
* notification arrives.
*
* @param handler the Response handler
* @param accept the Accept option
* @return the CoAP observe relation
*/
public CoapObserveRelation observeAndWait(CoapHandler handler, int accept) {
Request request = Request.newGet().setURI(uri).setObserve();
request.getOptions().setAccept(accept);
return observeAndWait(request, handler);
}
代码示例来源: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: eclipse/californium
/**
* Verifies that only GET requests can be marked for establishing an observe relation.
*/
@Test
public void setObserveFailsForNonGetRequest() {
Code[] illegalCodes = new Code[]{ Code.DELETE, Code.POST, Code.PUT };
for (Code code : illegalCodes) {
try {
Request req = new Request(code);
req.setObserve();
fail("should not be able to set observe option on " + code + " request");
} catch (IllegalStateException e) {
// as expected
}
}
}
代码示例来源:origin: eclipse/leshan
@Override
public void visit(ObserveRequest request) {
coapRequest = Request.newGet();
if (request.getContentFormat() != null)
coapRequest.getOptions().setAccept(request.getContentFormat().getCode());
coapRequest.setObserve();
setTarget(coapRequest, request.getPath());
// add context info to the observe request
coapRequest.setUserContext(ObserveUtil.createCoapObserveRequestContext(endpoint, registrationId, request));
}
内容来源于网络,如有侵权,请联系作者删除!