Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 19, 2008, 9:50:36 PM (16 years ago)
Author:
landauf
Message:

added chat overlay

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/network/Server.cc

    r1952 r1953  
    5858#include "packet/DeleteObjects.h"
    5959#include <util/Convert.h>
     60#include "ChatListener.h"
    6061
    6162namespace network
     
    8586  * @param bindAddress Address to listen on
    8687  */
    87   Server::Server(int port, std::string bindAddress) {
     88  Server::Server(int port, const std::string& bindAddress) {
    8889    timeSinceLastUpdate_=0;
    8990    connection = new ConnectionManager(port, bindAddress);
     
    128129  }
    129130
    130   bool Server::processChat(std::string message, unsigned int playerID){
     131  bool Server::processChat(const std::string& message, unsigned int playerID){
    131132    ClientInformation *temp = ClientInformation::getBegin();
    132133    packet::Chat *chat;
     
    138139      temp = temp->next();
    139140    }
    140     COUT(1) << "Player " << playerID << ": " << message << std::endl;
     141//    COUT(1) << "Player " << playerID << ": " << message << std::endl;
    141142    return true;
    142143  }
     
    304305      listener++;
    305306    }
    306    
     307
    307308    newid++;
    308309
     
    367368  }
    368369
    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){
    370379    ClientInformation *temp = ClientInformation::getBegin();
    371380    packet::Chat *chat;
    372381    while(temp){
    373       chat = new packet::Chat(message, Host::getPlayerID());
     382      chat = new packet::Chat(message, clientID);
    374383      chat->setClientID(temp->getID());
    375384      if(!chat->send())
     
    377386      temp = temp->next();
    378387    }
    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
    380392    return true;
    381393  }
Note: See TracChangeset for help on using the changeset viewer.