From 9f266f1ed5f45d6c673eb7b3fe6276f73ac99252 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 30 Nov 2018 17:50:47 +0100 Subject: core: move state to connection --- src/control_connection.hpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/control_connection.hpp') diff --git a/src/control_connection.hpp b/src/control_connection.hpp index 679a2ff..24d3276 100644 --- a/src/control_connection.hpp +++ b/src/control_connection.hpp @@ -27,6 +27,13 @@ struct control_connection : keyed, std::enable_shared_from_t virtual void on_error(pointer connection, boost::system::error_code) {} }; + enum struct state : std::underlying_type_t + { + unknown, + fresh, + established, + }; + /** * @internal * @brief Construct a new control connection object @@ -40,14 +47,14 @@ struct control_connection : keyed, std::enable_shared_from_t * * @returns true iff. the listener was not already in the listener set */ - bool add(listener * listener); + bool add(listener *listener); /** * @brief Remove the given listener from this control connection's listener set * * @return true iff. the listener was previously registered with this control connection */ - bool remove(listener * listener); + bool remove(listener *listener); /** * @brief Start I/O processing for this control connection @@ -61,6 +68,10 @@ struct control_connection : keyed, std::enable_shared_from_t void send(message message); + void update(state state); + + state current_state() const; + private: friend pointer make_control_connection(protocol::socket &&socket); @@ -72,7 +83,7 @@ struct control_connection : keyed, std::enable_shared_from_t std::istream m_input{&m_in}; std::ostream m_output{&m_out}; std::set m_listeners{}; - bool m_running{}; + state m_state{}; }; control_connection::pointer make_control_connection(control_connection::protocol::socket &&socket); -- cgit v1.2.3