blob: 711d24c087cfb79ab43e2dd3959d1f7faab969ef [file] [log] [blame]
Andrew Brown3f2521a2015-01-17 22:10:15 -08001/*
andrewsbrown4feb2da2015-03-03 16:05:29 -08002 * jndn-utils
3 * Copyright (c) 2015, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU Lesser General Public License,
7 * version 3, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT ANY
10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
12 * more details.
Andrew Brown3f2521a2015-01-17 22:10:15 -080013 */
14package com.intel.jndn.utils;
15
16import java.io.IOException;
andrewsbrown8d5ae292015-07-01 17:38:22 -070017import java.util.concurrent.CompletableFuture;
Andrew Brown3f2521a2015-01-17 22:10:15 -080018import net.named_data.jndn.Data;
19import net.named_data.jndn.Face;
Andrew Brown3f2521a2015-01-17 22:10:15 -080020import net.named_data.jndn.Interest;
andrewsbrown8d5ae292015-07-01 17:38:22 -070021import net.named_data.jndn.Name;
Andrew Brown3f2521a2015-01-17 22:10:15 -080022
23/**
andrewsbrown69d53292015-03-17 19:37:34 +010024 * Base functionality provided by all NDN clients in this package.
Andrew Brown3f2521a2015-01-17 22:10:15 -080025 *
26 * @author Andrew Brown <andrew.brown@intel.com>
27 */
andrewsbrown69d53292015-03-17 19:37:34 +010028public interface Client {
Andrew Brown3f2521a2015-01-17 22:10:15 -080029
Andrew Brown7b1daf32015-01-19 16:36:01 -080030 /**
andrewsbrown8372eaa2015-02-23 10:08:17 -080031 * Asynchronously request the Data for an Interest. This will send the
andrewsbrown8d5ae292015-07-01 17:38:22 -070032 * Interest and return immediately; with this method, the user is responsible
33 * for calling {@link Face#processEvents()} in order for the
34 * {@link CompletableFuture} to complete.
Andrew Browndb457052015-02-21 15:41:58 -080035 *
andrewsbrown8d5ae292015-07-01 17:38:22 -070036 * @param face the {@link Face} on which to make the request; call
37 * {@link Face#processEvents()} separately to complete the request
38 * @param interest the {@link Interest} to send over the network
39 * @return a future {@link Data} packet
Andrew Browndb457052015-02-21 15:41:58 -080040 */
andrewsbrown8d5ae292015-07-01 17:38:22 -070041 public CompletableFuture<Data> getAsync(Face face, Interest interest);
Andrew Browndb457052015-02-21 15:41:58 -080042
43 /**
andrewsbrown8d5ae292015-07-01 17:38:22 -070044 * Convenience method for calling
45 * {@link #getAsync(net.named_data.jndn.Face, net.named_data.jndn.Interest)}
46 * with a default {@link Interest} packet.
Andrew Brown7b1daf32015-01-19 16:36:01 -080047 *
andrewsbrown8d5ae292015-07-01 17:38:22 -070048 * @param face the {@link Face} on which to make the request; call
49 * {@link Face#processEvents()} separately to complete the request
50 * @param name the {@link Name} to wrap inside a default {@link Interest}
51 * @return a future {@link Data} packet
52 */
53 public CompletableFuture<Data> getAsync(Face face, Name name);
54
55 /**
56 * Synchronously retrieve the {@link Data} for an {@link Interest}; this will
57 * block until complete (i.e. either the data is received or the interest
58 * times out).
59 *
60 * @param face the {@link Face} on which to make the request; this method will
61 * call {@link Face#processEvents()} at a configurable interval until complete
62 * or timeout
63 * @param interest the {@link Interest} to send over the network
64 * @return a {@link Data} packet
65 * @throws java.io.IOException if the request fails
Andrew Brown7b1daf32015-01-19 16:36:01 -080066 */
andrewsbrown69d53292015-03-17 19:37:34 +010067 public Data getSync(Face face, Interest interest) throws IOException;
andrewsbrown8d5ae292015-07-01 17:38:22 -070068
69 /**
70 * Convenience method for calling
71 * {@link #getSync(net.named_data.jndn.Face, net.named_data.jndn.Interest)}
72 * with a default {@link Interest} packet.
73 *
74 * @param face the {@link Face} on which to make the request; call
75 * {@link Face#processEvents()} separately to complete the request
76 * @param name the {@link Name} to wrap inside a default {@link Interest}
77 * @return a {@link Data} packet
78 * @throws java.io.IOException if the request fails
79 */
80 public Data getSync(Face face, Name name) throws IOException;
Andrew Brown3f2521a2015-01-17 22:10:15 -080081}