summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-11-15 05:31:31 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-11-15 05:31:31 +0100
commit96c08734ad0501d2dda58dcd2a617f149e7159be (patch)
tree57ba2159a49fb5ab0137576a5f26d33e034657c8
parentbe08c29dd5e18c41b5c2f05b7178bab90f04e026 (diff)
Moved recv_queue from ConnectionBase to client Connection.
-rw-r--r--common/connectionbase.cpp13
-rw-r--r--common/connectionbase.h9
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