blob: e38d38d6743775d7bc87b038c8db2c1c0dd6b512 [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
Andrew Brown3f2521a2015-01-17 22:10:15 -080016import net.named_data.jndn.Data;
17import net.named_data.jndn.Face;
Andrew Brown3f2521a2015-01-17 22:10:15 -080018import net.named_data.jndn.Interest;
andrewsbrown8d5ae292015-07-01 17:38:22 -070019import net.named_data.jndn.Name;
Andrew Brown3f2521a2015-01-17 22:10:15 -080020
Andrew Brown85234ea2016-09-07 13:41:29 -070021import java.io.IOException;
22import java.util.concurrent.CompletableFuture;
23
Andrew Brown3f2521a2015-01-17 22:10:15 -080024/**
andrewsbrown69d53292015-03-17 19:37:34 +010025 * Base functionality provided by all NDN clients in this package.
Andrew Brown3f2521a2015-01-17 22:10:15 -080026 *
Andrew Brown85234ea2016-09-07 13:41:29 -070027 * @author Andrew Brown, andrew.brown@intel.com
Andrew Brown3f2521a2015-01-17 22:10:15 -080028 */
andrewsbrown69d53292015-03-17 19:37:34 +010029public interface Client {
Andrew Brown3f2521a2015-01-17 22:10:15 -080030
Andrew Brown7b1daf32015-01-19 16:36:01 -080031 /**
andrewsbrown8372eaa2015-02-23 10:08:17 -080032 * Asynchronously request the Data for an Interest. This will send the
andrewsbrown8d5ae292015-07-01 17:38:22 -070033 * Interest and return immediately; with this method, the user is responsible
34 * for calling {@link Face#processEvents()} in order for the
35 * {@link CompletableFuture} to complete.
Andrew Browndb457052015-02-21 15:41:58 -080036 *
andrewsbrown8d5ae292015-07-01 17:38:22 -070037 * @param face the {@link Face} on which to make the request; call
38 * {@link Face#processEvents()} separately to complete the request
39 * @param interest the {@link Interest} to send over the network
40 * @return a future {@link Data} packet
Andrew Browndb457052015-02-21 15:41:58 -080041 */
Andrew Brown85234ea2016-09-07 13:41:29 -070042 CompletableFuture<Data> getAsync(Face face, Interest interest);
Andrew Browndb457052015-02-21 15:41:58 -080043
44 /**
andrewsbrown8d5ae292015-07-01 17:38:22 -070045 * Convenience method for calling
46 * {@link #getAsync(net.named_data.jndn.Face, net.named_data.jndn.Interest)}
47 * with a default {@link Interest} packet.
Andrew Brown7b1daf32015-01-19 16:36:01 -080048 *
andrewsbrown8d5ae292015-07-01 17:38:22 -070049 * @param face the {@link Face} on which to make the request; call
50 * {@link Face#processEvents()} separately to complete the request
51 * @param name the {@link Name} to wrap inside a default {@link Interest}
52 * @return a future {@link Data} packet
53 */
Andrew Brown85234ea2016-09-07 13:41:29 -070054 CompletableFuture<Data> getAsync(Face face, Name name);
andrewsbrown8d5ae292015-07-01 17:38:22 -070055
56 /**
57 * Synchronously retrieve the {@link Data} for an {@link Interest}; this will
58 * block until complete (i.e. either the data is received or the interest
59 * times out).
60 *
61 * @param face the {@link Face} on which to make the request; this method will
62 * call {@link Face#processEvents()} at a configurable interval until complete
63 * or timeout
64 * @param interest the {@link Interest} to send over the network
65 * @return a {@link Data} packet
66 * @throws java.io.IOException if the request fails
Andrew Brown7b1daf32015-01-19 16:36:01 -080067 */
Andrew Brown85234ea2016-09-07 13:41:29 -070068 Data getSync(Face face, Interest interest) throws IOException;
andrewsbrown8d5ae292015-07-01 17:38:22 -070069
70 /**
71 * Convenience method for calling
72 * {@link #getSync(net.named_data.jndn.Face, net.named_data.jndn.Interest)}
73 * with a default {@link Interest} packet.
74 *
75 * @param face the {@link Face} on which to make the request; call
76 * {@link Face#processEvents()} separately to complete the request
77 * @param name the {@link Name} to wrap inside a default {@link Interest}
78 * @return a {@link Data} packet
79 * @throws java.io.IOException if the request fails
80 */
Andrew Brown85234ea2016-09-07 13:41:29 -070081 Data getSync(Face face, Name name) throws IOException;
Andrew Brown3f2521a2015-01-17 22:10:15 -080082}