From cb15df6147ca7c41c15d1ab7ece91cc45319ab50 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 12 Jun 2011 20:29:19 +0200 Subject: Minor changes to work with the reworked message classes. --- common | 2 +- server.cpp | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/common b/common index 1f97ccd..e483f46 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 1f97ccdac792c0b5b07972e7d4b2f28416046ea8 +Subproject commit e483f468085379a986cbc48bb13a7983315475cf diff --git a/server.cpp b/server.cpp index 33abb00..88a672d 100644 --- a/server.cpp +++ b/server.cpp @@ -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 > chunks = c->check_chunks(); for(std::set >::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(); } -- cgit v1.2.3