dpyMwSubscriber.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 /********************************************************************************
9  ********************************* INCLUDES *************************************
10  ********************************************************************************/
11 
12 #include <azmq/socket.hpp>
13 #include <azmq/message.hpp>
14 #include <azmq/util/scope_guard.hpp>
15 
16 #include <boost/shared_ptr.hpp>
17 #include <boost/asio.hpp>
18 #include <boost/bind.hpp>
19 #include <boost/function.hpp>
20 #include <boost/enable_shared_from_this.hpp>
21 
22 namespace asio = boost::asio;
27 class DpyMwSubscriber: public boost::enable_shared_from_this<DpyMwSubscriber>
28 {
29  /********************************************************************************
30  ***************************** PUBLIC FUNCTIONS *********************************
31  ********************************************************************************/
32 public:
33  DpyMwSubscriber(boost::asio::io_service& io, std::string pubUrl);
34  ~DpyMwSubscriber();
35  void start();
36  void stop();
37  void restart();
38 
39  /********************************************************************************
40  ***************************** PUBLIC FUNCTIONS *********************************
41  ********************************************************************************/
42 private:
43  void doAsyncReceive();
44 
45  /********************************************************************************
46  **************************** PRIVATE VARIABLES *********************************
47  ********************************************************************************/
48 private:
49  boost::asio::io_service& mIo;
50  azmq::sub_socket m_subscriberSocket;
51  std::string m_PubUrl;
52  bool m_working;
53  std::string m_message_subscriber;
55  /********************************************************************************
56  **************************** PUBLIC VARIABLES *********************************
57  ********************************************************************************/
58 public:
59  std::function<void(const std::string &msg)> m_handler;
61 };
Subscriber class.
Definition: dpyMwSubscriber.h:27
std::function< void(const std::string &msg)> m_handler
Handler function to call from the client.
Definition: dpyMwSubscriber.h:59