Changeset 1953 for code/branches/objecthierarchy/src/network/Server.cc
- Timestamp:
- Oct 19, 2008, 9:50:36 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/network/Server.cc
r1952 r1953 58 58 #include "packet/DeleteObjects.h" 59 59 #include <util/Convert.h> 60 #include "ChatListener.h" 60 61 61 62 namespace network … … 85 86 * @param bindAddress Address to listen on 86 87 */ 87 Server::Server(int port, std::stringbindAddress) {88 Server::Server(int port, const std::string& bindAddress) { 88 89 timeSinceLastUpdate_=0; 89 90 connection = new ConnectionManager(port, bindAddress); … … 128 129 } 129 130 130 bool Server::processChat( std::stringmessage, unsigned int playerID){131 bool Server::processChat(const std::string& message, unsigned int playerID){ 131 132 ClientInformation *temp = ClientInformation::getBegin(); 132 133 packet::Chat *chat; … … 138 139 temp = temp->next(); 139 140 } 140 COUT(1) << "Player " << playerID << ": " << message << std::endl;141 // COUT(1) << "Player " << playerID << ": " << message << std::endl; 141 142 return true; 142 143 } … … 304 305 listener++; 305 306 } 306 307 307 308 newid++; 308 309 … … 367 368 } 368 369 369 bool Server::chat(std::string message){ 370 bool Server::chat(const std::string& message){ 371 return this->sendChat(message, Host::getPlayerID()); 372 } 373 374 bool Server::broadcast(const std::string& message){ 375 return this->sendChat(message, CLIENTID_UNKNOWN); 376 } 377 378 bool Server::sendChat(const std::string& message, unsigned int clientID){ 370 379 ClientInformation *temp = ClientInformation::getBegin(); 371 380 packet::Chat *chat; 372 381 while(temp){ 373 chat = new packet::Chat(message, Host::getPlayerID());382 chat = new packet::Chat(message, clientID); 374 383 chat->setClientID(temp->getID()); 375 384 if(!chat->send()) … … 377 386 temp = temp->next(); 378 387 } 379 COUT(1) << "Player " << Host::getPlayerID() << ": " << message << std::endl; 388 // COUT(1) << "Player " << Host::getPlayerID() << ": " << message << std::endl; 389 for (orxonox::ObjectList<ChatListener>::iterator it = orxonox::ObjectList<ChatListener>::begin(); it != orxonox::ObjectList<ChatListener>::end(); ++it) 390 it->incomingChat(message, clientID); 391 380 392 return true; 381 393 }
Note: See TracChangeset
for help on using the changeset viewer.