diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-10-10 11:39:25 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2016-10-10 11:39:25 +0200 |
commit | 2e71bf974f42cfe9edf9c8289602eec0c7ecadf9 (patch) | |
tree | 574bd00266dacf3dc7b21d6f601131c85340663b /src/RemoteControl.h | |
parent | bbafa23de92eb542f4c8266d484aed9faf88d360 (diff) | |
parent | 4576c71f10dc009ce0dd9aedbc2f81a3e1a8be0e (diff) | |
download | dabmux-2e71bf974f42cfe9edf9c8289602eec0c7ecadf9.tar.gz dabmux-2e71bf974f42cfe9edf9c8289602eec0c7ecadf9.tar.bz2 dabmux-2e71bf974f42cfe9edf9c8289602eec0c7ecadf9.zip |
Merge next into servicelinking
Diffstat (limited to 'src/RemoteControl.h')
-rw-r--r-- | src/RemoteControl.h | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/src/RemoteControl.h b/src/RemoteControl.h index fe8ac42..d8b3b6b 100644 --- a/src/RemoteControl.h +++ b/src/RemoteControl.h @@ -199,25 +199,25 @@ extern RemoteControllers rcs; class RemoteControllerTelnet : public BaseRemoteController { public: RemoteControllerTelnet() - : m_running(false), m_fault(false), + : m_active(false), + m_io_service(), + m_fault(false), m_port(0) { } RemoteControllerTelnet(int port) - : m_running(true), m_fault(false), - m_child_thread(&RemoteControllerTelnet::process, this, 0), - m_port(port) { } + : m_active(port > 0), + m_io_service(), + m_fault(false), + m_port(port) + { + restart(); + } + RemoteControllerTelnet& operator=(const RemoteControllerTelnet& other) = delete; RemoteControllerTelnet(const RemoteControllerTelnet& other) = delete; - ~RemoteControllerTelnet() { - m_running = false; - m_fault = false; - if (m_port) { - m_child_thread.interrupt(); - m_child_thread.join(); - } - } + ~RemoteControllerTelnet(); virtual bool fault_detected() { return m_fault; } @@ -233,6 +233,10 @@ class RemoteControllerTelnet : public BaseRemoteController { void reply(boost::asio::ip::tcp::socket& socket, std::string message); + void handle_accept( + const boost::system::error_code& boost_error, + boost::shared_ptr< boost::asio::ip::tcp::socket > socket, + boost::asio::ip::tcp::acceptor& acceptor); std::vector<std::string> tokenise_(std::string message) { std::vector<std::string> all_tokens; @@ -244,7 +248,9 @@ class RemoteControllerTelnet : public BaseRemoteController { return all_tokens; } - std::atomic<bool> m_running; + std::atomic<bool> m_active; + + boost::asio::io_service m_io_service; /* This is set to true if a fault occurred */ std::atomic<bool> m_fault; @@ -262,12 +268,12 @@ class RemoteControllerTelnet : public BaseRemoteController { class RemoteControllerZmq : public BaseRemoteController { public: RemoteControllerZmq() - : m_running(false), m_fault(false), + : m_active(false), m_fault(false), m_zmqContext(1), m_endpoint("") { } RemoteControllerZmq(const std::string& endpoint) - : m_running(true), m_fault(false), + : m_active(not endpoint.empty()), m_fault(false), m_zmqContext(1), m_endpoint(endpoint), m_child_thread(&RemoteControllerZmq::process, this) { } @@ -275,14 +281,7 @@ class RemoteControllerZmq : public BaseRemoteController { RemoteControllerZmq& operator=(const RemoteControllerZmq& other) = delete; RemoteControllerZmq(const RemoteControllerZmq& other) = delete; - ~RemoteControllerZmq() { - m_running = false; - m_fault = false; - if (!m_endpoint.empty()) { - m_child_thread.interrupt(); - m_child_thread.join(); - } - } + ~RemoteControllerZmq(); virtual bool fault_detected() { return m_fault; } @@ -296,7 +295,7 @@ class RemoteControllerZmq : public BaseRemoteController { void send_fail_reply(zmq::socket_t &pSocket, const std::string &error); void process(); - std::atomic<bool> m_running; + std::atomic<bool> m_active; /* This is set to true if a fault occurred */ std::atomic<bool> m_fault; |