本文整理了Java中org.eclipse.californium.core.coap.Response.setType
方法的一些代码示例,展示了Response.setType
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.setType
方法的具体详情如下:
包路径:org.eclipse.californium.core.coap.Response
类名称:Response
方法名:setType
暂无
代码示例来源:origin: eclipse/californium
@Override
public void onRetransmission() {
synchronized (exchange) {
ObserveRelation relation = exchange.getRelation();
final Response next = relation.getNextControlNotification();
if (next != null) {
LOGGER.fine("The notification has timed out and there is a fresher notification for the retransmission");
// Cancel the original retransmission and send the fresh
// notification here
response.cancel();
// Convert all notification retransmissions to CON
if (next.getType() != Type.CON) {
next.setType(Type.CON);
prepareSelfReplacement(exchange, next);
}
relation.setCurrentControlNotification(next);
relation.setNextControlNotification(null);
// Create a new task for sending next response so that we
// can leave the sync-block
executor.execute(new Runnable() {
public void run() {
ObserveLayer.super.sendResponse(exchange, next);
}
});
}
}
}
代码示例来源:origin: org.eclipse.californium/californium-core
@Override
public void onRetransmission() {
synchronized (exchange) {
ObserveRelation relation = exchange.getRelation();
final Response next = relation.getNextControlNotification();
if (next != null) {
LOGGER.fine("The notification has timed out and there is a fresher notification for the retransmission");
// Cancel the original retransmission and send the fresh notification here
response.cancel();
// Convert all notification retransmissions to CON
if (next.getType() != Type.CON) {
next.setType(Type.CON);
prepareSelfReplacement(exchange, next);
}
relation.setCurrentControlNotification(next);
relation.setNextControlNotification(null);
// Create a new task for sending next response so that we can leave the sync-block
executor.execute(new Runnable() {
public void run() {
ObserveLayer.super.sendResponse(exchange, next);
}
});
}
}
}
代码示例来源:origin: eclipse/californium
@Override
public void handleGET(CoapExchange exchange) {
int delay = this.delay.getAndSet(0);
if (0 < delay) {
try {
Thread.sleep(delay);
} catch (InterruptedException e) {
}
}
if (reject.compareAndSet(true, false)) {
exchange.reject();
} else {
Response response = new Response(ResponseCode.CONTENT);
response.setPayload(currentResponse);
response.setType(type);
exchange.respond(response);
}
}
代码示例来源:origin: eclipse/californium
public void handleGET(CoapExchange exchange) {
Response response = new Response(CONTENT);
response.setType(respType); // respType is altered throughout the test cases
response.setPayload(respPayload); // payload is altered throughout the test cases
exchange.respond(response);
}
代码示例来源:origin: org.eclipse.californium/californium-core
if (exchange.getCurrentRequest().isAcknowledged()) {
response.setType(Type.CON);
} else {
exchange.getCurrentRequest().setAcknowledged(true);
response.setType(Type.ACK);
response.setMID(exchange.getCurrentRequest().getMID());
response.setType(Type.NON);
代码示例来源:origin: eclipse/californium
if (exchange.getCurrentRequest().isAcknowledged()) {
response.setType(Type.CON);
} else {
exchange.getCurrentRequest().setAcknowledged(true);
response.setType(Type.ACK);
response.setMID(exchange.getCurrentRequest().getMID());
response.setType(Type.NON);
代码示例来源:origin: org.eclipse.californium/californium-core
response.setType(Type.CON);
relation.cancel();
} else {
response.setType(Type.CON);
} else {
if (response.getType()==null) response.setType(Type.NON);
代码示例来源:origin: eclipse/californium
response.setType(Type.CON);
relation.cancel();
} else {
response.setType(Type.CON);
} else {
response.setType(Type.NON);
代码示例来源:origin: org.eclipse.californium/californium-core
exchange.getCurrentRequest().setType(Type.CON);
} else if (exchange.getCurrentResponse() != null) {
exchange.getCurrentResponse().setType(Type.CON);
代码示例来源:origin: eclipse/californium
} else if (observeType != null) {
response.setType(observeType);
代码示例来源:origin: eclipse/californium
exchange.getCurrentRequest().setType(Type.CON);
} else if (exchange.getCurrentResponse() != null) {
exchange.getCurrentResponse().setType(Type.CON);
代码示例来源:origin: org.eclipse.californium/californium-core
} else if (observeType != null) {
response.setType(observeType);
代码示例来源:origin: eclipse/californium
@Test public void testResponseParsing() {
Response response = new Response(ResponseCode.CONTENT);
response.setType(Type.NON);
response.setMID(expectedMid);
response.setToken(new byte[] { 22, -1, 0, 78, 100, 22 });
response.getOptions().addETag(new byte[] { 1, 0, 0, 0, 0, 1 })
.addLocationPath("/one/two/three/four/five/six/seven/eight/nine/ten")
.addOption(new Option(57453, "Arbitrary".hashCode())).addOption(new Option(19205, "Arbitrary1"))
.addOption(new Option(19205, "Arbitrary2")).addOption(new Option(19205, "Arbitrary3"));
RawData rawData = serializer.serializeResponse(response);
Response result = (Response) parser.parseMessage(rawData);
assertEquals(response.getMID(), result.getMID());
assertArrayEquals(response.getToken(), result.getToken());
assertEquals(response.getOptions().asSortedList(), result.getOptions().asSortedList());
}
代码示例来源:origin: eclipse/californium
@Test public void testUTF8Encoding() {
Response response = new Response(ResponseCode.CONTENT);
response.setType(Type.NON);
response.setMID(expectedMid);
response.setToken(new byte[] {});
response.getOptions().addLocationPath("ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ").addLocationPath("γλώσσα")
.addLocationPath("пустынных").addLocationQuery("ვეპხის=யாமறிந்த").addLocationQuery("⠊⠀⠉⠁⠝=⠑⠁⠞⠀⠛⠇⠁⠎⠎");
response.setPayload("⠊⠀⠉⠁⠝⠀⠑⠁⠞⠀⠛⠇⠁⠎⠎⠀⠁⠝⠙⠀⠊⠞⠀⠙⠕⠑⠎⠝⠞⠀⠓⠥⠗⠞⠀⠍⠑");
RawData rawData = serializer.serializeResponse(response);
Response result = (Response) parser.parseMessage(rawData);
assertEquals("ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ/γλώσσα/пустынных", response.getOptions().getLocationPathString());
assertEquals("ვეპხის=யாமறிந்த&⠊⠀⠉⠁⠝=⠑⠁⠞⠀⠛⠇⠁⠎⠎", response.getOptions().getLocationQueryString());
assertEquals("⠊⠀⠉⠁⠝⠀⠑⠁⠞⠀⠛⠇⠁⠎⠎⠀⠁⠝⠙⠀⠊⠞⠀⠙⠕⠑⠎⠝⠞⠀⠓⠥⠗⠞⠀⠍⠑", result.getPayloadString());
assertEquals(response.getMID(), result.getMID());
}
}
内容来源于网络,如有侵权,请联系作者删除!