aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/includes/hicn/transport/interfaces/socket_producer.h
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/includes/hicn/transport/interfaces/socket_producer.h')
-rw-r--r--libtransport/includes/hicn/transport/interfaces/socket_producer.h44
1 files changed, 33 insertions, 11 deletions
diff --git a/libtransport/includes/hicn/transport/interfaces/socket_producer.h b/libtransport/includes/hicn/transport/interfaces/socket_producer.h
index 27b603dfe..2627b3138 100644
--- a/libtransport/includes/hicn/transport/interfaces/socket_producer.h
+++ b/libtransport/includes/hicn/transport/interfaces/socket_producer.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:
@@ -23,6 +23,8 @@
#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/utils/event_thread.h>
+#include <hicn/transport/utils/noncopyable.h>
namespace transport {
@@ -34,12 +36,28 @@ namespace interface {
using namespace core;
-class ProducerSocket {
+class ProducerSocket : private utils::NonCopyable {
public:
+ /**
+ * @brief This class is used by the transport to notify events to the
+ * application.
+ */
+ class Callback {
+ public:
+ /**
+ * @brief This will invoked in an error occurred in the production protocol.
+ *
+ * @param ec - An error code describing the error.
+ */
+ virtual void produceError(const std::error_code &ec) noexcept = 0;
+ };
+
explicit ProducerSocket(
int protocol = ProductionProtocolAlgorithms::BYTE_STREAM);
- explicit ProducerSocket(int protocol, asio::io_service &io_service);
+ explicit ProducerSocket(int protocol, ::utils::EventThread &worker);
+
+ ProducerSocket(ProducerSocket &&other) noexcept;
virtual ~ProducerSocket();
@@ -63,21 +81,18 @@ class ProducerSocket {
uint32_t produceDatagram(const Name &content_name,
std::unique_ptr<utils::MemBuf> &&buffer);
- void asyncProduce(const Name &suffix, const uint8_t *buf, size_t buffer_size,
- bool is_last = true, uint32_t *start_offset = nullptr);
-
- void asyncProduce(Name content_name, std::unique_ptr<utils::MemBuf> &&buffer,
- bool is_last, uint32_t offset,
- uint32_t **last_segment = nullptr);
-
void produce(ContentObject &content_object);
- void serveForever();
+ void sendMapme();
void stop();
+ void start();
+
asio::io_service &getIoService();
+ int setSocketOption(int socket_option_key, Callback *socket_option_value);
+
int setSocketOption(int socket_option_key, uint32_t socket_option_value);
int setSocketOption(int socket_option_key,
@@ -108,6 +123,10 @@ class ProducerSocket {
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<auth::Verifier> &socket_option_value);
+
int setSocketOption(int socket_option_key,
const std::string &socket_option_value);
@@ -136,6 +155,9 @@ class ProducerSocket {
int getSocketOption(int socket_option_key,
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);
protected: