diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2018-11-30 17:50:47 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2018-11-30 17:50:47 +0100 |
| commit | 9f266f1ed5f45d6c673eb7b3fe6276f73ac99252 (patch) | |
| tree | 6bd9bba8d8f9cf6c497cd07d4ebdef1cdaf6420f /src/control_connection.hpp | |
| parent | 3abece6f0a7edca476ee0c493f30dda8f8bcefd5 (diff) | |
| download | wanda-9f266f1ed5f45d6c673eb7b3fe6276f73ac99252.tar.xz wanda-9f266f1ed5f45d6c673eb7b3fe6276f73ac99252.zip | |
core: move state to connection
Diffstat (limited to 'src/control_connection.hpp')
| -rw-r--r-- | src/control_connection.hpp | 17 |
1 files changed, 14 insertions, 3 deletions
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<control_connection>, std::enable_shared_from_t virtual void on_error(pointer connection, boost::system::error_code) {} }; + enum struct state : std::underlying_type_t<std::byte> + { + unknown, + fresh, + established, + }; + /** * @internal * @brief Construct a new control connection object @@ -40,14 +47,14 @@ struct control_connection : keyed<control_connection>, std::enable_shared_from_t * * @returns <code>true</code> 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 <code>true</code> 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<control_connection>, 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<control_connection>, std::enable_shared_from_t std::istream m_input{&m_in}; std::ostream m_output{&m_out}; std::set<listener *> m_listeners{}; - bool m_running{}; + state m_state{}; }; control_connection::pointer make_control_connection(control_connection::protocol::socket &&socket); |
