salsa  0.4.0
PublisherZmq.cc
1 #include <PublisherZmq.hh>
2 
3 namespace Salsa {
4 PublisherZmq::PublisherZmq(std::string url) : Publisher(url)
5 {
9 
10  mpSocket = zsock_new_pub(url.c_str());
11 }
13 {
17 
18  zsock_destroy(&mpSocket);
19 }
20 
21 void PublisherZmq::publish(std::string id, std::string data)
22 {
26 
27  if (!mpSocket) {
28  SPD_ERROR("PublisherZmq::publish() mpSocket is null");
29  return;
30  }
31 
32  SPD_TRACE("PublisherZmq::publish() Sending msg id={} data={}", id, data);
33 
34  zmsg_t * msg = zmsg_new();
35  zmsg_addstr(msg, "salsa"); // Later we change it to something meaningfull
36  zmsg_addstr(msg, id.data());
37  zmsg_addstr(msg, data.data());
38  zmsg_send(&msg, mpSocket);
39 }
40 
41 } // namespace Salsa
virtual ~PublisherZmq()
Definition: PublisherZmq.cc:12
zsock_t * mpSocket
Socket that... does stuff...
Definition: PublisherZmq.hh:25
virtual void publish(std::string id, std::string data)
Publish TODO publish what?
Definition: PublisherZmq.cc:21
Base Publisher class.
Definition: Publisher.hh:14
PublisherZmq(std::string url=">tcp://localhost:1234")
Definition: PublisherZmq.cc:4
std::string url() const
Returns url.
Definition: Publisher.hh:23