summaryrefslogtreecommitdiff
path: root/server/connection.h
diff options
context:
space:
mode:
Diffstat (limited to 'server/connection.h')
-rw-r--r--server/connection.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/server/connection.h b/server/connection.h
new file mode 100644
index 0000000..aba7734
--- /dev/null
+++ b/server/connection.h
@@ -0,0 +1,38 @@
+#ifndef CONNECTION_H
+#define CONNECTION_H
+
+#include <boost/asio.hpp>
+#include <boost/enable_shared_from_this.hpp>
+
+#include "../common/connectionbase.h"
+
+class Connection : public ConnectionBase, public boost::enable_shared_from_this<Connection> {
+ private:
+ friend class TCPServer;
+
+ boost::asio::ip::tcp::socket socket;
+
+ Connection(boost::asio::io_service& io_service);
+
+ private:
+ //! Callback for when data is read.
+ void handle_read(uint8_t* data, std::size_t bytes);
+
+ //! Callback for when data is written.
+ void handle_write();
+
+ protected:
+ //! Implements request_data().
+ virtual void request_data(std::size_t bytes);
+
+ //! Implements write_data().
+ virtual void write_data(uint8_t* data, std::size_t bytes);
+
+ public:
+ typedef boost::shared_ptr<Connection> p;
+
+ //! Constructs a new instance and returns a shared pointer.
+ static p create(boost::asio::io_service& io_service);
+};
+
+#endif