本文整理汇总了Java中org.eclipse.californium.core.coap.Request.newGet方法的典型用法代码示例。如果您正苦于以下问题:Java Request.newGet方法的具体用法?Java Request.newGet怎么用?Java Request.newGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.californium.core.coap.Request
的用法示例。
在下文中一共展示了Request.newGet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reregister
import org.eclipse.californium.core.coap.Request; //导入方法依赖的package包/类
/**
* Refreshes the Observe relationship with a new GET request with same token
* and options. The method also resets the notification orderer, since the
* server might have rebooted and started the observe sequence number from
* the beginning.
*/
public void reregister() {
if (!request.isCanceled()) {
Request refresh = Request.newGet();
refresh.setDestination(request.getDestination());
refresh.setDestinationPort(request.getDestinationPort());
// use same Token
refresh.setToken(request.getToken());
// copy options, but set Observe to zero
refresh.setOptions(request.getOptions());
refresh.setObserve();
// use same message observers
for (MessageObserver mo : request.getMessageObservers()) {
refresh.addMessageObserver(mo);
}
endpoint.sendRequest(refresh);
// update request in observe handle for correct cancellation
this.request = refresh;
// reset orderer to accept any sequence number since server might have rebooted
this.orderer = new ObserveNotificationOrderer();
}
}
示例2: proactiveCancel
import org.eclipse.californium.core.coap.Request; //导入方法依赖的package包/类
/**
* Proactive Observe cancellation:
* Cancel the observe relation by sending a GET with Observe=1.
*/
public void proactiveCancel() {
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);
// cancel old ongoing request
request.cancel();
setCanceled(true);
}
示例3: newRequest
import org.eclipse.californium.core.coap.Request; //导入方法依赖的package包/类
public static Request newRequest(String method) {
if (method.equalsIgnoreCase("GET")) {
return Request.newGet();
} else if (method.equalsIgnoreCase("POST")) {
return Request.newPost();
} else if (method.equalsIgnoreCase("PUT")) {
return Request.newPut();
} else if (method.equalsIgnoreCase("DELETE")) {
return Request.newDelete();
} else if (method.equalsIgnoreCase("DISCOVER")) {
return Request.newGet();
} else if (method.equalsIgnoreCase("OBSERVE")) {
Request request = Request.newGet();
request.setObserve();
return request;
} else {
System.err.println("Unknown method: " + method);
return null;
}
}