summaryrefslogtreecommitdiff
path: root/server/connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'server/connection.cpp')
-rw-r--r--server/connection.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/server/connection.cpp b/server/connection.cpp
index 32b24da..f7315b2 100644
--- a/server/connection.cpp
+++ b/server/connection.cpp
@@ -29,6 +29,10 @@ void Connection::request_data(std::size_t bytes) {
// boost::asio::placeholders::error
}
+void Connection::got_message(const Message::p& msg) {
+ recv_callback(msg);
+}
+
void Connection::write_data(uint8_t* data, std::size_t bytes) {
boost::asio::async_write(socket, boost::asio::buffer(data, bytes),
boost::bind(&Connection::handle_write, shared_from_this()));
@@ -37,3 +41,9 @@ void Connection::write_data(uint8_t* data, std::size_t bytes) {
Connection::p Connection::create(boost::asio::io_service& io_service) {
return Connection::p(new Connection(io_service));
}
+
+void Connection::recv(boost::function<void (Message::p)> f) {
+ recv_callback = f;
+
+ start_recv();
+} \ No newline at end of file