Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 7, 2011, 3:11:16 PM (13 years ago)
Author:
landauf
Message:

enhanced chat system. chat related code is now separated into network-side code (located in Host, Client, Server) and client-side code (located in ChatManager).
note that there are now two chat related listeners: NetworkChatListener, which is used to send chat from the network to ChatManager, and ChatListener, which is used to send online and offline chat from ChatManager to the actual chat interfaces (ChatOverlay, ChatInputHandler, …).
the "chat" console command now supports a second argument which is the clientID of the receiver. this allows private messages (or gameplay messages directed to only one specific player).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/output/src/libraries/network/Client.cc

    r8807 r8829  
    116116  }
    117117
    118   bool Client::processChat(const std::string& message, unsigned int playerID)
    119   {
    120 //    orxout(message) << "Player " << playerID << ": " << message << endl;
    121     return true;
    122   }
    123 
    124118  void Client::printRTT()
    125119  {
     
    128122
    129123  /**
    130    * This function implements the method of sending a chat message to the server
     124   * @brief Sends a chat message to the server.
    131125   * @param message message to be sent
    132    * @return result(true/false)
     126   * @param sourceID the ID of the sender
     127   * @param targetID the ID of the receiver
    133128   */
    134   bool Client::chat(const std::string& message)
    135   {
    136     packet::Chat *m = new packet::Chat(message, Host::getPlayerID());
    137     return m->send(static_cast<Host*>(this));
    138   }
    139 
     129  void Client::doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
     130  {
     131    // send the message to the server
     132    packet::Chat* packet = new packet::Chat(message, sourceID, targetID);
     133    packet->send(static_cast<Host*>(this));
     134  }
     135
     136  /**
     137   * @brief Gets called if a packet::Chat packet is received. Calls the parent function which passes the message to the listeners.
     138   */
     139  void Client::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
     140  {
     141    // call the parent function which passes the message to the listeners
     142    Host::doReceiveChat(message, sourceID, targetID);
     143  }
    140144
    141145  /**
     
    203207    Game::getInstance().popState();
    204208  }
    205  
     209
    206210  void Client::processPacket(packet::Packet* packet)
    207211  {
     
    216220      packet->process(static_cast<Host*>(this));
    217221  }
    218 
    219 
    220 
    221 
    222222}
Note: See TracChangeset for help on using the changeset viewer.