diff options
Diffstat (limited to 'libtransport/includes/hicn/transport/interfaces/socket_consumer.h')
-rw-r--r-- | libtransport/includes/hicn/transport/interfaces/socket_consumer.h | 69 |
1 files changed, 29 insertions, 40 deletions
diff --git a/libtransport/includes/hicn/transport/interfaces/socket_consumer.h b/libtransport/includes/hicn/transport/interfaces/socket_consumer.h index 2447f9b5b..1c709eb72 100644 --- a/libtransport/includes/hicn/transport/interfaces/socket_consumer.h +++ b/libtransport/includes/hicn/transport/interfaces/socket_consumer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Cisco and/or its affiliates. + * Copyright (c) 2021 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -15,18 +15,16 @@ #pragma once +#include <hicn/transport/auth/verifier.h> #include <hicn/transport/config.h> +#include <hicn/transport/core/asio_wrapper.h> #include <hicn/transport/core/name.h> #include <hicn/transport/core/prefix.h> #include <hicn/transport/interfaces/callbacks.h> #include <hicn/transport/interfaces/socket_options_default_values.h> #include <hicn/transport/interfaces/socket_options_keys.h> -#include <hicn/transport/security/verifier.h> - -#ifndef ASIO_STANDALONE -#define ASIO_STANDALONE -#endif -#include <asio/io_service.hpp> +#include <hicn/transport/utils/event_thread.h> +#include <hicn/transport/utils/noncopyable.h> #define CONSUMER_FINISHED 0 #define CONSUMER_BUSY 1 @@ -49,7 +47,7 @@ using namespace core; * It allows to retrieve an application data from one/many producers, by * hiding all the complexity of the transport protocol used underneath. */ -class ConsumerSocket { +class ConsumerSocket : private utils::NonCopyable { public: /** * The ReadCallback is a class which can be used by the transport for both @@ -128,7 +126,7 @@ class ConsumerSocket { * * @param ec - An error code describing the error. */ - virtual void readError(const std::error_code ec) noexcept = 0; + virtual void readError(const std::error_code &ec) noexcept = 0; /** * This callback will be invoked when the whole content is retrieved. The @@ -170,7 +168,12 @@ class ConsumerSocket { * 110, 104-117 * - RTC: Real time communication */ - explicit ConsumerSocket(int protocol, asio::io_service &io_service); + explicit ConsumerSocket(int protocol, ::utils::EventThread &worker); + + /** + * @brief Move contructor + */ + ConsumerSocket(ConsumerSocket &&other) noexcept; /** * @brief Destroy the consumer socket. @@ -204,20 +207,10 @@ class ConsumerSocket { * content retrieval succeeded. This information can be obtained from the * error code in CONTENT_RETRIEVED callback. */ - int consume(const Name &name); - int asyncConsume(const Name &name); + int consume(const Name &name, bool blocking = false); /** - * Verify the packets containing a key after the origin of the key has been - * validated by the client. - * - * @return true if all packets are valid, false otherwise - */ - bool verifyKeyPackets(); - - /** - * Stops the consumer socket. If several downloads are queued (using - * asyncConsume), this call stops just the current one. + * Stops the consumer socket. */ void stop(); @@ -251,23 +244,18 @@ class ConsumerSocket { int setSocketOption(int socket_option_key, ConsumerContentObjectCallback socket_option_value); - int setSocketOption( - int socket_option_key, - ConsumerContentObjectVerificationFailedCallback socket_option_value); - - int setSocketOption( - int socket_option_key, - ConsumerContentObjectVerificationCallback socket_option_value); - int setSocketOption(int socket_option_key, ConsumerInterestCallback socket_option_value); int setSocketOption(int socket_option_key, interface::IcnObserver *socket_option_value); + int setSocketOption(int socket_option_key, + const std::shared_ptr<auth::Signer> &socket_option_value); + int setSocketOption( int socket_option_key, - const std::shared_ptr<utils::Verifier> &socket_option_value); + const std::shared_ptr<auth::Verifier> &socket_option_value); int setSocketOption(int socket_option_key, const std::string &socket_option_value); @@ -275,6 +263,9 @@ class ConsumerSocket { int setSocketOption(int socket_option_key, ConsumerTimerCallback socket_option_value); + int setSocketOption(int socket_option_key, + StrategyCallback socket_option_value); + int getSocketOption(int socket_option_key, double &socket_option_value); int getSocketOption(int socket_option_key, uint32_t &socket_option_value); @@ -286,21 +277,16 @@ class ConsumerSocket { int getSocketOption(int socket_option_key, ConsumerContentObjectCallback **socket_option_value); - int getSocketOption( - int socket_option_key, - ConsumerContentObjectVerificationFailedCallback **socket_option_value); - - int getSocketOption( - int socket_option_key, - ConsumerContentObjectVerificationCallback **socket_option_value); - int getSocketOption(int socket_option_key, ConsumerInterestCallback **socket_option_value); int getSocketOption(int socket_option_key, IcnObserver **socket_option_value); int getSocketOption(int socket_option_key, - std::shared_ptr<utils::Verifier> &socket_option_value); + std::shared_ptr<auth::Signer> &socket_option_value); + + int getSocketOption(int socket_option_key, + std::shared_ptr<auth::Verifier> &socket_option_value); int getSocketOption(int socket_option_key, std::string &socket_option_value); @@ -308,6 +294,9 @@ class ConsumerSocket { ConsumerTimerCallback **socket_option_value); int getSocketOption(int socket_option_key, + StrategyCallback **socket_option_value); + + int getSocketOption(int socket_option_key, interface::TransportStatistics **socket_option_value); protected: |