include/ControlDataSender.h
include/ControlDataSender.h File Reference
Namespaces
| Name |
|---|
| Acl |
Classes
| Name | |
|---|---|
| class | Acl::ControlDataSender A ControlDataSender can send control signals to one or more receivers using a network connection. A single ControlDataSender can connect to multiple receivers, all identified by a UUID. The class is controlled using an ISystemControllerInterface; this interface is responsible for setting up connections to receivers. The ControlDataSender can send asynchronous requests to (all) the receivers and get a response back. Each response is identified with a request ID as well as the UUID of the responding receiver. The ControlDataSender can also receive status messages from the receivers. |
| struct | Acl::ControlDataSender::Settings Settings for a ControlDataSender. |
Source code
// Copyright (c) 2024, Ateliere. All rights reserved.
#pragma once
#include <functional>
#include <memory>
#include <vector>
#include <ISystemControllerInterface.h>
#include "ControlDataCommon.h"
namespace Acl {
class ControlDataSender final {
public:
enum class SendRequestStatus {
kSuccess,
kFailed,
kSendFailedForSome,
kSenderNotConfigured,
kNoConnectedReceiver,
kInternalError
};
struct Settings {
std::function<void(const ControlDataCommon::Response&)>
mResponseCallback; // Callback for response messages from receivers
std::function<void(const ControlDataCommon::StatusMessage&)>
mStatusMessageCallback; // Callback for status messages from receivers
std::function<void(const ControlDataCommon::ConnectionEvent&)>
mConnectionEventCallback; // Callback for connection events that has been detected by the sender, or passed
// to it from a connected receiver
};
ControlDataSender();
~ControlDataSender();
[[nodiscard]] bool configure(const std::shared_ptr<ISystemControllerInterface>& controllerInterface,
const Settings& settings) const;
SendRequestStatus sendRequestToReceivers(std::string_view request,
uint64_t& requestId,
const UUID& requester = UUID::kNilUUID,
int8_t hops = -1) const;
[[nodiscard]] std::vector<UUID> getDirectlyConnectedReceivers() const;
static std::string getVersion();
// ControlDataSender is not copyable
ControlDataSender(ControlDataSender const&) = delete; // Copy construct
ControlDataSender& operator=(ControlDataSender const&) = delete; // Copy assign
private:
class Impl;
std::unique_ptr<Impl> pImpl;
};
} // namespace Acl