1 #include "hmbdc/Copyright.hpp" 3 #include "hmbdc/app/tcpcast/SendTransportEngine.hpp" 4 #include "hmbdc/Traits.hpp" 6 namespace hmbdc {
namespace app {
namespace tcpcast {
12 using ptr = std::shared_ptr<Sender>;
16 : transport_(transport)
33 template <
typename Message,
typename T
34 ,
typename = std::enable_if<std::is_integral<T>::value>>
35 void send(Message&& msg, T len) {
37 using raw =
typename remove_reference<Message>::type;
38 static_assert(std::is_trivially_destructible<raw>::value,
"cannot send message with dtor");
39 static_assert(!is_base_of<hasMemoryAttachment, raw>::value
41 ,
"hasMemoryAttachment has to the first base for Message");
42 transport_->queueBytes(
43 topic_, raw::typeTag, &msg, static_cast<size_t>(len));
55 template <
typename... Messages>
56 void send(Messages&&... msgs) {
57 transport_->queue(topic_, std::forward<Messages>(msgs)...);
69 template <
typename... Messages>
71 return transport_->tryQueue(topic_, std::forward<Messages>(msgs)...);
82 template <
typename Message,
typename ... Args>
84 transport_->template queueInPlace<Message>(topic_, std::forward<Args>(args)...);
97 void sendBytes(uint16_t tag,
void const* bytes,
size_t len) {
98 transport_->queueBytes(topic_, tag, bytes, len);
101 SendTransport::ptr transport_;
fascade class for sending network messages
Definition: Sender.hpp:11
void sendInPlace(Args &&... args)
send a message asynchronizely - avoiding Message copying by directly constructing the message in the ...
Definition: Sender.hpp:83
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
Definition: TypedString.hpp:74
void send(Messages &&... msgs)
send a batch of message asynchronizely
Definition: Sender.hpp:56
Definition: Traits.hpp:35
a singleton that holding tcpcast resources
Definition: NetContext.hpp:44
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:97
void send(Message &&msg, T len)
send a message's first bytes
Definition: Sender.hpp:35
bool trySend(Messages &&... msgs)
try to send a batch of message asynchronizely
Definition: Sender.hpp:70