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>;
15 Sender(SendTransportEngine::ptr transport,
Topic const& t)
16 : transport_(transport)
33 template <
typename Message,
typename T
34 ,
typename = enable_if<is_integral<T>::value>>
35 void send(Message&& msg, T len) {
36 using raw =
typename remove_reference<Message>::type;
37 static_assert(!is_base_of<hasMemoryAttachment, raw>::value
39 ,
"hasMemoryAttachment has to the first base for Message");
40 static_assert(!is_base_of<hasFileAttachment, raw>::value
42 ,
"hasFileAttachment has to the first base for Message");
43 transport_->queueBytes(
44 topic_, raw::typeTag, &msg, static_cast<size_t>(len));
56 template <
typename... Messages>
57 void send(Messages&&... msgs) {
58 transport_->queue(topic_, std::forward<Messages>(msgs)...);
70 template <
typename... Messages>
72 return transport_->tryQueue(topic_, std::forward<Messages>(msgs)...);
83 template <
typename Message,
typename ... Args>
85 transport_->template queueInPlace<Message>(topic_, std::forward<Args>(args)...);
98 void sendBytes(uint16_t tag,
void const* bytes,
size_t len) {
99 transport_->queueBytes(topic_, tag, bytes, len);
102 SendTransport::ptr transport_;
bool trySend(Messages &&...msgs)
try to send a batch of message asynchronizely
Definition: Sender.hpp:71
void send(Messages &&...msgs)
send a batch of message asynchronizely
Definition: Sender.hpp:57
fascade class for sending network messages
Definition: Sender.hpp:11
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
Definition: NetContext.hpp:28
Definition: Traits.hpp:35
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:98
void send(Message &&msg, T len)
send a message's first bytes
Definition: Sender.hpp:35
void sendInPlace(Args &&...args)
send a message asynchronizely - avoiding Message copying by directly constructing the message in the ...
Definition: Sender.hpp:84
Definition: Client.hpp:11