diff options
m--------- | common | 0 | ||||
-rw-r--r-- | server.cpp | 18 |
2 files changed, 6 insertions, 12 deletions
diff --git a/common b/common -Subproject 1f97ccdac792c0b5b07972e7d4b2f28416046ea +Subproject e483f468085379a986cbc48bb13a7983315475c @@ -27,9 +27,9 @@ void Server::handle_connect(Connection::p connection) { message::Hello h; //h.b = boost::asio::buffer(&version, sizeof(version)); std::cout << "reading payload" << std::endl; - h.read(connection->socket); + h.recv(connection->socket); std::cout << "fetching version" << std::endl; - uint8_t version = h.read_version(); + uint8_t version = h.get_version(); std::cout << "version: " << (int)version << std::endl; message::Message m((boost::format("Welcome [colour='FFFF0000']%s[colour='FFFFFFFF'], you've connected to [colour='FF0000FF']%s") % connection->socket.local_endpoint().address().to_string() @@ -98,8 +98,8 @@ void Server::handle_type(const boost::system::error_code& error, size_t bytes_tr void Server::handle_pos(Connection::p c) { message::Pos m; - m.read(c->socket); - m.get_pos(c->pos.x, c->pos.y, c->pos.z); + m.recv(c->socket); + c->pos = m.get_pos(); std::set<std::pair<int64_t, int64_t> > chunks = c->check_chunks(); for(std::set<std::pair<int64_t, int64_t> >::iterator it = chunks.begin(); it != chunks.end(); it++) { @@ -114,7 +114,7 @@ void Server::handle_pos(Connection::p c) { void Server::handle_chunk(Connection::p c) { message::Chunk m; - m.read(c->socket); + m.recv(c->socket); int64_t x, y; m.get_coords(x, y); } @@ -122,12 +122,6 @@ void Server::handle_chunk(Connection::p c) { void Server::handle_message(Connection::p c) { message::Message m; - m.read(c->socket); - // call this to tell the object we know the string length - uint16_t len = m.get_len(); - std::cout << "string length: " << len << std::endl; - - // string is fetched on next read - m.read(c->socket); + m.recv(c->socket); std::string s = m.get_str(); } |