/** * 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. * * @return this Request */ public Request setObserve() { getOptions().setObserve(0); return this; }
/** * Sets CoAP's observe option to the value of 1 to proactively cancel. * * @return this Request */ public Request setObserveCancel() { getOptions().setObserve(1); return this; }
/** * Sets CoAP's observe option to the value of 1 to proactively cancel. * * @return this Request * @throws IllegalStateException if this is not a GET request. */ public final Request setObserveCancel() { if (code != CoAP.Code.GET) { throw new IllegalStateException("observe option can only be set on a GET request"); } getOptions().setObserve(1); return this; }
/** * 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. * * @return this Request * @throws IllegalStateException if this is not a GET request. */ public final Request setObserve() { if (code != CoAP.Code.GET) { throw new IllegalStateException("observe option can only be set on a GET request"); } getOptions().setObserve(0); return this; }
public void set(Message message) { message.getOptions().setObserve(observe); } });
/** * Verifies that the getByteArray() method does not set the Message's <em>bytes</em> property. */ @Test public void testGetByteArrayDoesNotAlterMessage() { // GIVEN a CoAP request Request req = Request.newGet(); req.setToken(new byte[]{0x00}); req.getOptions().setObserve(0); req.setDestination(InetAddress.getLoopbackAddress()); // WHEN serializing the request to a byte array serializer.getByteArray(req); // THEN the serialized byte array is not written to the request's bytes property assertNull(req.getBytes()); }
response.getOptions().setObserve(notificationOrderer.getCurrent());
response.getOptions().setObserve(notificationOrderer.getCurrent());
/** * Verifies that the serializeRequest() method sets the Message's <em>bytes</em> property. */ @Test public void testSerializeRequestStoresBytesInMessage() { // GIVEN a CoAP request Request req = Request.newGet(); req.setToken(new byte[]{0x00}); req.getOptions().setObserve(0); req.setDestination(InetAddress.getLoopbackAddress()); // WHEN serializing the request to a RawData object RawData raw = serializer.serializeRequest(req); // THEN the serialized byte array is stored in the request's bytes property assertNotNull(req.getBytes()); assertThat(raw.getBytes(), is(req.getBytes())); } }
assembled.getOptions().setObserve(observe);
assembled.getOptions().setObserve(observe);
case OptionNumberRegistry.SIZE1: setSize1(option.getIntegerValue()); break; case OptionNumberRegistry.SIZE2: setSize2(option.getIntegerValue()); break; case OptionNumberRegistry.OBSERVE: setObserve(option.getIntegerValue()); break; default: getOthersInternal().add(option);
case OptionNumberRegistry.SIZE1: setSize1(option.getIntegerValue()); break; case OptionNumberRegistry.SIZE2: setSize2(option.getIntegerValue()); break; case OptionNumberRegistry.OBSERVE: setObserve(option.getIntegerValue()); break; default: getOthersInternal().add(option);