summaryrefslogtreecommitdiff
path: root/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'server.cpp')
-rw-r--r--server.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/server.cpp b/server.cpp
index 77956fa..891708c 100644
--- a/server.cpp
+++ b/server.cpp
@@ -36,11 +36,14 @@ void Server::handle_connect(Connection::p connection) {
% connection->socket.remote_endpoint().address().to_string()).str());
m.send(connection->socket);
- message::Player p(0, Vector3(0, 52, 0), "foooooooooooooooooooooo");
- p.send(connection->socket);
+ message::Player player(connection->get_id(), connection->pos, connection->socket.local_endpoint().address().to_string());
- message::Player p2(1, Vector3(5, 50, 5), "b");
- p2.send(connection->socket);
+ for(std::list<Connection::p>::iterator it = clients.begin(); it != clients.end(); it++) {
+ player.send((*it)->socket);
+ Connection::p c = *it;
+ message::Player other(c->get_id(), c->pos, c->socket.local_endpoint().address().to_string());
+ other.send(connection->socket);
+ }
clients.push_back(connection);
@@ -111,6 +114,13 @@ void Server::handle_pos(Connection::p c) {
chunk.set_data(obj->heights);
chunk.send(c->socket);
}
+ for(std::list<Connection::p>::iterator it = clients.begin(); it != clients.end(); it++) {
+ if(*it == c)
+ continue;
+
+ message::Pos p(c->get_id(), c->pos);
+ p.send((*it)->socket);
+ }
}
void Server::handle_chunk(Connection::p c) {