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(!is_base_of<hasMemoryAttachment, raw>::value
40 ,
"hasMemoryAttachment has to the first base for Message");
41 transport_->queueBytes(
42 topic_, raw::typeTag, &msg, static_cast<size_t>(len));
54 template <
typename... Messages>
55 void send(Messages&&... msgs) {
56 transport_->queue(topic_, std::forward<Messages>(msgs)...);
68 template <
typename... Messages>
70 return transport_->tryQueue(topic_, std::forward<Messages>(msgs)...);
81 template <
typename Message,
typename ... Args>
83 transport_->template queueInPlace<Message>(topic_, std::forward<Args>(args)...);
96 void sendBytes(uint16_t tag,
void const* bytes,
size_t len) {
97 transport_->queueBytes(topic_, tag, bytes, len);
100 SendTransport::ptr transport_;
bool trySend(Messages &&...msgs)
try to send a batch of message asynchronizely
Definition: Sender.hpp:69
void send(Messages &&...msgs)
send a batch of message asynchronizely
Definition: Sender.hpp:55
fascade class for sending network messages
Definition: Sender.hpp:11
topic as in the publish / subscribe communication paradigm
Definition: Topic.hpp:14
Definition: TypedString.hpp:74
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:96
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:82