当前位置: 首页>>代码示例>>Java>>正文


Java Response.getDestinationPort方法代码示例

本文整理汇总了Java中org.eclipse.californium.core.coap.Response.getDestinationPort方法的典型用法代码示例。如果您正苦于以下问题:Java Response.getDestinationPort方法的具体用法?Java Response.getDestinationPort怎么用?Java Response.getDestinationPort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.californium.core.coap.Response的用法示例。


在下文中一共展示了Response.getDestinationPort方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendResponse

import org.eclipse.californium.core.coap.Response; //导入方法依赖的package包/类
@Override
public void sendResponse(Exchange exchange, Response response) {
	
	if (response.getDestination() == null)
		throw new NullPointerException("Response has no destination address");
	if (response.getDestinationPort() == 0)
		throw new NullPointerException("Response has no destination port");
	
	matcher.sendResponse(exchange, response);
	
	/* 
	 * Logging here causes significant performance loss.
	 * If necessary, add an interceptor that logs the messages,
	 * e.g., the MessageTracer.
	 */
	
	for (MessageInterceptor interceptor:interceptors)
		interceptor.sendResponse(response);

	// MessageInterceptor might have canceled
	if (!response.isCanceled())
		connector.send(serializer.serialize(response));
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:24,代码来源:CoapEndpoint.java

示例2: sendResponse

import org.eclipse.californium.core.coap.Response; //导入方法依赖的package包/类
public void sendResponse(Exchange exchange, Response response) {
	
	// ensure MID is set
	if (response.getMID() == Message.NONE) {
		response.setMID(currendMID.getAndIncrement()%(1<<16));
	}
	
	// ensure Token is set
	response.setToken(exchange.getCurrentRequest().getToken());

	// If this is a CON notification we now can forget all previous NON notifications
	if (response.getType() == Type.CON || response.getType() == Type.ACK) {
		ObserveRelation relation = exchange.getRelation();
		if (relation != null) {
			removeNotificatoinsOf(relation);
		}
	}
	
	// Blockwise transfers are identified by URI and remote endpoint
	if (response.getOptions().hasBlock2()) {
		Request request = exchange.getCurrentRequest();
		KeyUri idByUri = new KeyUri(request.getURI(), response.getDestination().getAddress(), response.getDestinationPort());
		// Observe notifications only send the first block, hence do not store them as ongoing
		if (exchange.getResponseBlockStatus()!=null && !response.getOptions().hasObserve()) {
			// Remember ongoing blockwise GET requests
			if (ongoingExchanges.put(idByUri, exchange)==null) {
				LOGGER.fine("Ongoing Block2 started late, storing "+idByUri + " for " + request);
			} else {
				LOGGER.fine("Ongoing Block2 continued, storing "+idByUri + " for " + request);
			}
		} else {
			LOGGER.fine("Ongoing Block2 completed, cleaning up "+idByUri + " for " + request);
			ongoingExchanges.remove(idByUri);
		}
	}
	
	// Insert CON and NON to match ACKs and RSTs to the exchange.
	// Do not insert ACKs and RSTs.
	if (response.getType() == Type.CON || response.getType() == Type.NON) {
		KeyMID idByMID = new KeyMID(response.getMID(), null, 0);
		exchangesByMID.put(idByMID, exchange);
	}
	
	// Only CONs and Observe keep the exchange active
	if (response.getType() != Type.CON && response.isLast()) {
		exchange.setComplete();
	}
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:49,代码来源:Matcher.java

示例3: serialize

import org.eclipse.californium.core.coap.Response; //导入方法依赖的package包/类
/**
 * Serializes the specified response. Message identifier, message code,
 * token, options and payload are converted into a byte array and wrapped in
 * a {@link RawData} object. The response's destination address and port are
 * stored as address and port in the RawData object.
 *
 * @param response the response
 * @return the response as raw data
 */
public RawData serialize(Response response) {
	byte[] bytes = response.getBytes();
	if (bytes == null)
		bytes = new DataSerializer().serializeResponse(response);
	response.setBytes(bytes);
	return new RawData(bytes, response.getDestination(), response.getDestinationPort());
}
 
开发者ID:iotoasis,项目名称:SI,代码行数:17,代码来源:Serializer.java


注:本文中的org.eclipse.californium.core.coap.Response.getDestinationPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。