summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-06-12 20:29:19 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-06-12 20:29:19 +0200
commitcb15df6147ca7c41c15d1ab7ece91cc45319ab50 (patch)
treebfaec8673cd59df1213d919b31767721432ea27b
parent291d092775f815d62677e2cec5726e76771a05d4 (diff)
Minor changes to work with the reworked message classes.
m---------common0
-rw-r--r--server.cpp18
2 files changed, 6 insertions, 12 deletions
diff --git a/common b/common
-Subproject 1f97ccdac792c0b5b07972e7d4b2f28416046ea
+Subproject e483f468085379a986cbc48bb13a7983315475c
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<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();
}