diff options
-rw-r--r-- | common/connectionbase.cpp | 13 | ||||
-rw-r--r-- | common/connectionbase.h | 9 |
2 files changed, 5 insertions, 17 deletions
diff --git a/common/connectionbase.cpp b/common/connectionbase.cpp index b399884..5dadf7d 100644 --- a/common/connectionbase.cpp +++ b/common/connectionbase.cpp @@ -66,7 +66,7 @@ void ConnectionBase::got_data(uint8_t* data, std::size_t bytes) { m->deserialize(data, bytes); } - recv_queue.push(m); + got_message(m); request_data(4); } @@ -85,17 +85,6 @@ void ConnectionBase::send(const Message::p& msg) { } } -Message::p ConnectionBase::recv() { - if(recv_queue.empty()) { - return Message::p(); - } - - Message::p msg = recv_queue.front(); - recv_queue.pop(); - - return msg; -} - ConnectionBase::ConnectionBase() { pending_size = 0; } diff --git a/common/connectionbase.h b/common/connectionbase.h index 78e3fe4..3e64551 100644 --- a/common/connectionbase.h +++ b/common/connectionbase.h @@ -9,8 +9,6 @@ class ConnectionBase { private: - std::queue<Message::p> recv_queue; - Message::Type pending_type; std::size_t pending_size; @@ -35,15 +33,16 @@ class ConnectionBase { //! \param bytes Size of data. virtual void write_data(uint8_t* data, std::size_t bytes) = 0; + //! Called when a message is received. + //! \param msg Received message. + virtual void got_message(const Message::p& msg) = 0; + public: ConnectionBase(); virtual ~ConnectionBase(); //! Send a message. void send(const Message::p& msg); - - //! Get received message or null if queue empty. - Message::p recv(); }; #endif |