summaryrefslogtreecommitdiff
path: root/server.h
blob: 992e792378feb5ef3bd641c5d8017fec7e7d2156 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef SERVER_H
#define SERVER_H

#include "connection.h"
#include "terrain_cache.h"

#include <boost/asio.hpp>
#include <boost/bind.hpp>

#include <list>

class Server {
	private:
		boost::asio::ip::tcp::acceptor acceptor;
		std::list<Connection::p> clients;

		TerrainCache::p cache;

	public:
		Server(boost::asio::io_service& io_service);

		void run();
		void start_accept();

		void handle_connect(Connection::p connection);
		void async_read(Connection::p connection);
		void handle_type(const boost::system::error_code& error, size_t bytes_transferred, Connection::p connection, uint8_t *_type);

		void handle_pos(Connection::p c);
		void handle_chunk(Connection::p c);
		void handle_message(Connection::p c);
};

#endif