From 7ff743b857f867180f5c766f0370bde9237932ff Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 12 Jun 2011 21:48:04 +0200 Subject: Broadcast received messages to all clients. --- server.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'server.cpp') diff --git a/server.cpp b/server.cpp index 88a672d..77956fa 100644 --- a/server.cpp +++ b/server.cpp @@ -42,6 +42,8 @@ void Server::handle_connect(Connection::p connection) { message::Player p2(1, Vector3(5, 50, 5), "b"); p2.send(connection->socket); + clients.push_back(connection); + async_read(connection); /*boost::asio::streambuf b; @@ -124,4 +126,9 @@ void Server::handle_message(Connection::p c) { m.recv(c->socket); std::string s = m.get_str(); + + for(std::list::iterator it = clients.begin(); it != clients.end(); it++) { + message::Message msg(s); + msg.send((*it)->socket); + } } -- cgit v1.2.3