/** * Creates a {@link CoapClient} that uses the same executor as this resource * and one of the endpoints that this resource belongs to. If no executor is * defined by this resource or any parent, the client will not have an * executor (it still works). If this resource is not yet added to a server * or the server has no endpoints, the client has no specific endpoint and * will use Californium's default endpoint. * * @param uri the uri * @return the CoAP client */ public CoapClient createClient(URI uri) { return createClient().setURI(uri.toString()); }
/** * Creates a {@link CoapClient} that uses the same executor as this resource * and one of the endpoints that this resource belongs to. If no executor is * defined by this resource or any parent, the client will not have an * executor (it still works). If this resource is not yet added to a server * or the server has no endpoints, the client has no specific endpoint and * will use Californium's default endpoint. * * @param uri the URI string * @return the CoAP client */ public CoapClient createClient(String uri) { return createClient().setURI(uri); }
/** * Creates a {@link CoapClient} that uses the same executor as this resource * and one of the endpoints that this resource belongs to. If no executor is * defined by this resource or any parent, the client will not have an * executor (it still works). If this resource is not yet added to a server * or the server has no endpoints, the client has no specific endpoint and * will use Californium's default endpoint. * * @param uri the uri * @return the CoAP client */ public CoapClient createClient(URI uri) { return createClient().setURI(uri.toString()); }
/** * Creates a {@link CoapClient} that uses the same executor as this resource * and one of the endpoints that this resource belongs to. If no executor is * defined by this resource or any parent, the client will not have an * executor (it still works). If this resource is not yet added to a server * or the server has no endpoints, the client has no specific endpoint and * will use Californium's default endpoint. * * @param uri the URI string * @return the CoAP client */ public CoapClient createClient(String uri) { return createClient().setURI(uri); }
try { Thread.sleep(6*1000); } catch (InterruptedException e) { } client.setURI(uri + "/obs-non").useNONs(); try { Thread.sleep(2*1000); } catch (InterruptedException e) { } client.setURI(uri + "/obs").useCONs(); try { Thread.sleep(2*1000); } catch (InterruptedException e) { } client.setURI(uri + "/obs-large"); try { Thread.sleep(6*1000); } catch (InterruptedException e) { } client.setURI(uri + "/obs-pumping");
System.out.println("Found " + links.size() + " resource(s)"); for (WebLink link : links) { client.setURI(link.getURI()); System.out.println("---------------\nGET " + link.getURI() + " with ct=40\n---------------"); Set<WebLink> links2 = LinkFormat.parse(client.get(MediaTypeRegistry.APPLICATION_LINK_FORMAT).getResponseText()); System.out.println("Found " + links2.size() + " resource(s)"); for (WebLink link2 : links2) { client.setURI(link2.getURI()); System.out.println("---------------\nGET " + link2.getURI() + "\n---------------"); CoapResponse response = client.get();
System.out.println(response.getResponseText()); client.setURI(uri + "/large-update"); System.out.println(response.getResponseText()); client.setURI(uri + "/large-create"); System.out.println(response.getResponseText()); client.setURI(uri + response.getOptions().getLocationString()); System.out.println(response.getResponseText()); client.setURI(uri + "/large-post"); System.out.println(response.getResponseText()); client.setURI(uri + "/large"); client.useEarlyNegotiation(16);
@Test public void testAdvancedUsesUriFromRequest() throws Exception { String unexistingUri = String.format("coap://%s:%d/%s", serverAddress.getHostString(), serverAddress.getPort(), "unexisting"); client.setURI(unexistingUri); final CountDownLatch latch = new CountDownLatch(1); Request request = new Request(Code.GET, Type.CON); request.setURI(uri); // Try a put and receive a METHOD_NOT_ALLOWED client.advanced(new TestHandler("Test 10") { @Override public void onLoad(CoapResponse response) { latch.countDown(); } }, request); assertTrue(latch.await(1, TimeUnit.SECONDS)); }
System.out.println(response.getResponseText()); client.setURI(uri + "/separate"); client.useCONs(); client.setURI(uri + "/test"); client.setURI(uri + "/seg1/seg2/seg3"); client.setURI(uri + "/query?first=1&second=2"); client.setURI(uri + "/separate"); client.setTimeout(10000); client.useNONs(); client.setURI(uri + "/test"); client.setTimeout(0); client.useCONs(); client.setURI(uri + "/location-query"); client.setURI(uri + "/multi-format"); client.setURI(uri + "/validate"); byte[] etag; client.setURI(uri + "/create1");