Java Code Examples for org.eclipse.californium.core.coap.Request#setURI()
The following examples show how to use
org.eclipse.californium.core.coap.Request#setURI() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoapTestBase.java From hono with Eclipse Public License 2.0 | 5 votes |
/** * Creates a CoAP request using the <em>coap</em> scheme. * * @param code The CoAP request code. * @param type The message type. * @param resource the resource path. * @param msgNo The message number. * @return The request to send. */ protected Request createCoapRequest( final Code code, final Type type, final String resource, final int msgNo) { final Request request = new Request(code, type); request.setURI(getCoapRequestUri(resource)); request.setPayload("hello " + msgNo); request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN); return request; }
Example 2
Source File: CoapTestBase.java From hono with Eclipse Public License 2.0 | 5 votes |
/** * Creates a CoAP request using the <em>coaps</em> scheme. * * @param code The CoAP request code. * @param type The message type. * @param resource the resource path. * @param payload The payload to send in the request body. * @return The request to send. */ protected Request createCoapsRequest( final Code code, final Type type, final String resource, final byte[] payload) { final Request request = new Request(code, type); request.setURI(getCoapsRequestUri(resource)); request.setPayload(payload); request.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN); return request; }
Example 3
Source File: CoapClient.java From SI with BSD 2-Clause "Simplified" License | 5 votes |
/** * Performs a CoAP ping and gives up after the given number of milliseconds. * * @param timeout the time to wait for a pong in ms * @return success of the ping */ public boolean ping(long timeout) { try { Request request = new Request(null, Type.CON); request.setToken(new byte[0]); request.setURI(uri); request.send().waitForResponse(timeout); return request.isRejected(); } catch (InterruptedException e) { // waiting was interrupted, which is fine } return false; }
Example 4
Source File: CoapClient.java From SI with BSD 2-Clause "Simplified" License | 5 votes |
/** * Performs a CoAP ping and gives up after the given number of milliseconds. * * @param timeout the time to wait for a pong in ms * @return success of the ping */ public boolean ping(long timeout) { try { Request request = new Request(null, Type.CON); request.setToken(new byte[0]); request.setURI(uri); request.send().waitForResponse(timeout); return request.isRejected(); } catch (InterruptedException e) { // waiting was interrupted, which is fine } return false; }
Example 5
Source File: CoapClient.java From SI with BSD 2-Clause "Simplified" License | 2 votes |
/** * Sends an advanced synchronous request that has to be configured by the developer. * * @param request the custom request * @return the CoAP response */ public CoapResponse advanced(Request request) { request.setURI(uri); return synchronous(request); }
Example 6
Source File: CoapClient.java From SI with BSD 2-Clause "Simplified" License | 2 votes |
/** * Sends an advanced asynchronous request that has to be configured by the * developer. * @param handler the response handler * @param request the custom request */ public void advanced(CoapHandler handler, Request request) { request.setURI(uri); asynchronous(request, handler); }
Example 7
Source File: CoapClient.java From SI with BSD 2-Clause "Simplified" License | 2 votes |
/** * Sends an advanced synchronous request that has to be configured by the developer. * * @param request the custom request * @return the CoAP response */ public CoapResponse advanced(Request request) { request.setURI(uri); return synchronous(request); }
Example 8
Source File: CoapClient.java From SI with BSD 2-Clause "Simplified" License | 2 votes |
/** * Sends an advanced asynchronous request that has to be configured by the * developer. * @param handler the response handler * @param request the custom request */ public void advanced(CoapHandler handler, Request request) { request.setURI(uri); asynchronous(request, handler); }