1 #include "hmbdc/Copyright.hpp"
3 #include "hmbdc/app/udpcast/SendTransportEngine.hpp"
4 #include "hmbdc/app/RequestReply.hpp"
9 namespace hmbdc {
namespace app {
namespace udpcast {
17 using ptr = std::shared_ptr<Sender>;
21 Sender(SendTransport::ptr transport,
Topic const& t)
22 : transport_(transport)
39 template <
typename Message,
typename T
40 ,
typename Enabled =
typename std::enable_if<std::is_integral<T>::value,
void>::type>
41 void send(Message&& msg, T len) {
42 using raw =
typename std::remove_reference<Message>::type;
43 static_assert(std::is_trivially_destructible<raw>::value,
"cannot send message with dtor");
44 transport_->queueBytes(
45 topic_, raw::typeTag, &msg, static_cast<size_t>(len));
57 template <
typename... Messages>
58 void send(Messages&&... msgs) {
59 transport_->queue(topic_, std::forward<Messages>(msgs)...);
71 template <
typename... Messages>
73 return transport_->tryQueue(topic_, std::forward<Messages>(msgs)...);
84 template <
typename Message,
typename ... Args>
86 transport_->template queueInPlace<Message>(topic_, std::forward<Args>(args)...);
99 void sendBytes(uint16_t tag,
void const* bytes,
size_t len) {
100 transport_->queueBytes(topic_, tag, bytes, len);
104 SendTransport::ptr transport_;
void sendInPlace(Args &&...args)
send a message asynchronizely - avoiding Message copying by directly constructing the message in the ...
Definition: Sender.hpp:85
a singleton that holding udpcast resources
Definition: NetContext.hpp:37
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
void send(Messages &&...msgs)
send a batch of message asynchronizely
Definition: Sender.hpp:58
void send(Message &&msg, T len)
send a message's first bytes
Definition: Sender.hpp:41
synchronous request reply interface for the Network Sender
Definition: RequestReply.hpp:166
fascade class for sending network messages
Definition: Sender.hpp:15
void sendBytes(uint16_t tag, void const *bytes, size_t len)
send a message asynchronizely by providing message in tag and bytes
Definition: Sender.hpp:99
bool trySend(Messages &&...msgs)
send a batch of message asynchronizely
Definition: Sender.hpp:72