本文整理了Java中org.eclipse.californium.core.coap.Request.getTokenString
方法的一些代码示例,展示了Request.getTokenString
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getTokenString
方法的具体详情如下:
包路径:org.eclipse.californium.core.coap.Request
类名称:Request
方法名:getTokenString
暂无
代码示例来源:origin: eclipse/californium
@Override
public void sendRequest(Exchange exchange, final Request request) {
exchange.setObserver(exchangeObserver);
exchangeStore.registerOutboundRequestWithTokenOnly(exchange);
LOGGER.log(Level.FINE, "Tracking open request using {0}", new Object[] { request.getTokenString() });
}
代码示例来源:origin: eclipse/californium
/**
* Constructs a new observe relation.
*
* @param endpoint the observing endpoint
* @param resource the observed resource
* @param exchange the exchange that tries to establish the observe relation
*/
public ObserveRelation(ObservingEndpoint endpoint, Resource resource, Exchange exchange) {
if (endpoint == null)
throw new NullPointerException();
if (resource == null)
throw new NullPointerException();
if (exchange == null)
throw new NullPointerException();
this.endpoint = endpoint;
this.resource = resource;
this.exchange = exchange;
this.established = false;
this.key = getSource().toString() + "#" + exchange.getRequest().getTokenString();
}
代码示例来源:origin: org.eclipse.californium/californium-core
/**
* Constructs a new observe relation.
*
* @param endpoint the observing endpoint
* @param resource the observed resource
* @param exchange the exchange that tries to establish the observe relation
*/
public ObserveRelation(ObservingEndpoint endpoint, Resource resource, Exchange exchange) {
if (endpoint == null)
throw new NullPointerException();
if (resource == null)
throw new NullPointerException();
if (exchange == null)
throw new NullPointerException();
this.endpoint = endpoint;
this.resource = resource;
this.exchange = exchange;
this.established = false;
this.key = getSource().toString() + "#" + exchange.getRequest().getTokenString();
}
代码示例来源:origin: eclipse/californium
@Override
public void sendRequest(final Exchange exchange, final Request request) {
observe(exchange);
exchangeStore.registerOutboundRequest(exchange);
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.log(
Level.FINER,
"Tracking open request [MID: {0}, Token: {1}]",
new Object[] { request.getMID(), request.getTokenString() });
}
}
代码示例来源:origin: org.eclipse.californium/californium-core
/**
* Formats a {@link Request} into a readable String representation.
*
* @param r the Request
* @return the pretty print
*/
public static String prettyPrint(Request r) {
StringBuilder sb = new StringBuilder();
sb.append("==[ CoAP Request ]=============================================").append(System.lineSeparator());
sb.append(String.format("MID : %d", r.getMID())).append(System.lineSeparator());
sb.append(String.format("Token : %s", r.getTokenString())).append(System.lineSeparator());
sb.append(String.format("Type : %s", r.getType().toString())).append(System.lineSeparator());
sb.append(String.format("Method : %s", r.getCode().toString())).append(System.lineSeparator());
sb.append(String.format("Options: %s", r.getOptions().toString())).append(System.lineSeparator());
sb.append(String.format("Payload: %d Bytes", r.getPayloadSize())).append(System.lineSeparator());
if (r.getPayloadSize() > 0 && MediaTypeRegistry.isPrintable(r.getOptions().getContentFormat())) {
sb.append("---------------------------------------------------------------").append(System.lineSeparator());
sb.append(r.getPayloadString());
sb.append(System.lineSeparator());
}
sb.append("===============================================================");
return sb.toString();
}
代码示例来源:origin: eclipse/californium
/**
* Formats a {@link Request} into a readable String representation.
*
* @param r the Request
* @return the pretty print
*/
public static String prettyPrint(Request r) {
StringBuilder sb = new StringBuilder();
sb.append("==[ CoAP Request ]=============================================").append(System.lineSeparator());
sb.append(String.format("MID : %d", r.getMID())).append(System.lineSeparator());
sb.append(String.format("Token : %s", r.getTokenString())).append(System.lineSeparator());
sb.append(String.format("Type : %s", r.getType().toString())).append(System.lineSeparator());
sb.append(String.format("Method : %s", r.getCode().toString())).append(System.lineSeparator());
sb.append(String.format("Options: %s", r.getOptions().toString())).append(System.lineSeparator());
sb.append(String.format("Payload: %d Bytes", r.getPayloadSize())).append(System.lineSeparator());
if (r.getPayloadSize() > 0 && MediaTypeRegistry.isPrintable(r.getOptions().getContentFormat())) {
sb.append("---------------------------------------------------------------").append(System.lineSeparator());
sb.append(r.getPayloadString());
sb.append(System.lineSeparator());
}
sb.append("===============================================================");
return sb.toString();
}
代码示例来源:origin: eclipse/californium
/**
* Reactive Observe cancellation: Cancel the observe relation by forgetting,
* which will trigger a RST. For TCP, {{@link #proactiveCancel()} will be
* executed.
*/
public void reactiveCancel() {
Request request = this.request;
if (CoAP.isTcpScheme(request.getScheme())) {
LOGGER.log(Level.INFO, "Change to cancel the observe {0} proactive over TCP.", request.getTokenString());
proactiveCancel();
} else {
// cancel old ongoing request
cancel();
}
}
代码示例来源:origin: eclipse/californium
@Override
public void onTimeout() {
ObserveRelation relation = exchange.getRelation();
LOGGER.log(
Level.INFO,
"Notification for token [{0}] timed out. Canceling all relations with source [{1}]",
new Object[]{ relation.getExchange().getRequest().getTokenString(), relation.getSource() });
relation.cancelAll();
}
代码示例来源:origin: org.eclipse.californium/californium-core
@Override
public String toString() {
String payload = getPayloadTracingString();
return String.format("%s-%-6s MID=%5d, Token=%s, OptionSet=%s, %s", getType(), getCode(), getMID(), getTokenString(), getOptions(), payload);
}
代码示例来源:origin: eclipse/californium
@Override
public String toString() {
String payload = getPayloadTracingString();
return String.format("%s-%-6s MID=%5d, Token=%s, OptionSet=%s, %s", getType(), getCode(), getMID(), getTokenString(), getOptions(), payload);
}
代码示例来源:origin: org.eclipse.californium/californium-core
@Override
public void onTimeout() {
ObserveRelation relation = exchange.getRelation();
LOGGER.info("Notification " + relation.getExchange().getRequest().getTokenString() + " timed out. Cancel all relations with source " + relation.getSource());
relation.cancelAll();
}
代码示例来源:origin: eclipse/californium
@Override
public void onCancel() {
if (!exchange.isComplete()) {
LOGGER.log(Level.FINE, "completing canceled request [MID={0}, token={1}]",
new Object[]{ exchange.getRequest().getMID(), exchange.getRequest().getTokenString() });
exchange.setComplete();
}
}
}
代码示例来源:origin: eclipse/leshan
public CoapMessage(Request request, boolean incoming) {
this(incoming, request.getType(), request.getMID(), request.getTokenString(), request.getOptions(), request
.getPayload());
this.code = request.getCode().toString();
}
代码示例来源:origin: eclipse/californium
payload.append(request.getTokenString());
代码示例来源:origin: eclipse/californium
protected final void appendRequestDetails(final Request request) {
if (request.isCanceled()) {
buffer.append("CANCELED ");
}
buffer.append(request.getType()).append(" [MID=").append(request.getMID())
.append(", T=").append(request.getTokenString()).append("], ")
.append(request.getCode()).append(", /").append(request.getOptions().getUriPathString());
appendBlockOption(1, request.getOptions().getBlock1());
appendBlockOption(2, request.getOptions().getBlock2());
appendObserveOption(request.getOptions());
appendSize1(request.getOptions());
appendEtags(request.getOptions());
}
代码示例来源:origin: eclipse/californium
Request request = this.request;
if (request.isCanceled()) {
throw new IllegalStateException("observe request already canceled! token " + request.getTokenString());
代码示例来源:origin: org.eclipse.californium/californium-core
Request request = this.request;
if (request.isCanceled()) {
throw new IllegalStateException("observe request already canceled! token " + request.getTokenString());
内容来源于网络,如有侵权,请联系作者删除!