Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9521 in orxonox.OLD for branches/proxy/src/lib/network


Ignore:
Timestamp:
Jul 27, 2006, 7:51:06 PM (18 years ago)
Author:
patrick
Message:

extended the callback function for message handlers to match the new sender/dest message structure

Location:
branches/proxy/src/lib/network
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/proxy/src/lib/network/message_manager.cc

    r9520 r9521  
    229229      // call the handler function and handle errors
    230230      if ( !(*(messageHandlerMap[(MessageType)messageType].cb))( (MessageType)messageType, data + i, messageLength,
    231                                                                  messageHandlerMap[(MessageType)messageType].someData, userId ) )
     231                                                                 messageHandlerMap[(MessageType)messageType].someData, senderId, destinationId ) )
    232232      {
    233233        // if the message is not handled correctly, bush it back to the incoming packets
     
    255255  for ( std::list<NetworkMessage>::iterator it = incomingMessageQueue.begin(); it != incomingMessageQueue.end();  )
    256256  {
    257     if ( (*(messageHandlerMap[it->messageType].cb))( it->messageType, it->data, it->length, messageHandlerMap[it->messageType].someData, it->number ) )
     257    if ( (*(messageHandlerMap[it->messageType].cb))( it->messageType, it->data, it->length, messageHandlerMap[it->messageType].someData,
     258                                                     /*it->number, */it->senderId, it->destinationId ) )
    258259    {
    259260      std::list<NetworkMessage>::iterator delIt = it;
  • branches/proxy/src/lib/network/message_manager.h

    r9519 r9521  
    4040
    4141
    42 typedef bool (*MessageCallback)( MessageType messageType, byte * data, int dataLength, void * someData, int userId );
     42typedef bool (*MessageCallback)( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId );
    4343
    4444enum RecieverType
  • branches/proxy/src/lib/network/network_game_manager.cc

    r9508 r9521  
    166166 * @return true on successfull handling else handler will be called again
    167167 */
    168 bool NetworkGameManager::delSynchronizeableHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId )
     168bool NetworkGameManager::delSynchronizeableHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId )
    169169{
    170170
     
    172172
    173173  if ( SharedNetworkData::getInstance()->isMasterServer() ||
    174        SharedNetworkData::getInstance()->isProxyServerActive() && SharedNetworkData::getInstance()->isUserClient(userId))
    175   {
    176     PRINTF(0)("Recieved DeleteSynchronizeable message from client %d!\n", userId);
     174       SharedNetworkData::getInstance()->isProxyServerActive() && SharedNetworkData::getInstance()->isUserClient(senderId))
     175  {
     176    PRINTF(0)("Recieved DeleteSynchronizeable message from client %d!\n", senderId);
    177177    return true;
    178178  }
     
    183183  if ( len != dataLength )
    184184  {
    185     PRINTF(2)("Recieved DeleteSynchronizeable message with incorrect size (%d) from client %d!\n", dataLength, userId);
     185    PRINTF(2)("Recieved DeleteSynchronizeable message with incorrect size (%d) from client %d!\n", dataLength, senderId);
    186186    return true;
    187187  }
     
    231231 * @return
    232232 */
    233 bool NetworkGameManager::preferedTeamHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId )
     233bool NetworkGameManager::preferedTeamHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId )
    234234{
    235235  assert( SharedNetworkData::getInstance()->isMasterServer() /*||  SharedNetworkData::getInstance()->isProxyServerActive()*/);
     
    240240  if ( len != dataLength )
    241241  {
    242     PRINTF(2)("Recieved DeleteSynchronizeable message with incorrect size (%d) from client %d!\n", dataLength, userId);
     242    PRINTF(2)("Recieved DeleteSynchronizeable message with incorrect size (%d) from client %d!\n", dataLength, senderId);
    243243    return true;
    244244  }
    245245
    246   NetworkGameManager::getInstance()->setPreferedTeam( userId, teamId );
     246  NetworkGameManager::getInstance()->setPreferedTeam( senderId, teamId );
    247247
    248248  return true;
     
    314314
    315315
    316 bool NetworkGameManager::chatMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId )
    317 {
    318   PRINTF(0)("NetworkGameManager::chatMessageHandler %d %d\n", userId, SharedNetworkData::getInstance()->getHostID() );
    319   if ( (SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/) && userId !=  SharedNetworkData::getInstance()->getHostID() )
     316bool NetworkGameManager::chatMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId )
     317{
     318  PRINTF(0)("NetworkGameManager::chatMessageHandler %d %d\n", senderId, SharedNetworkData::getInstance()->getHostID() );
     319  if ( (SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/) && senderId !=  SharedNetworkData::getInstance()->getHostID() )
    320320  {
    321321    MessageManager::getInstance()->sendMessage( messageType, data, dataLength, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
     
    329329  if ( dataLength < 3*INTSIZE )
    330330  {
    331     PRINTF(2)("got too small chatmessage from client %d\n", userId);
     331    PRINTF(2)("got too small chatmessage from client %d\n", senderId);
    332332
    333333    return true;
  • branches/proxy/src/lib/network/network_game_manager.h

    r9508 r9521  
    7070    NetworkGameManager();
    7171
    72     static bool delSynchronizeableHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId );
    73     static bool preferedTeamHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId );
    74     static bool chatMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId );
     72    static bool delSynchronizeableHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId );
     73    static bool preferedTeamHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId );
     74    static bool chatMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId );
    7575
    7676    void setPreferedTeam( int userId, int teamId );
  • branches/proxy/src/lib/network/player_stats.cc

    r9508 r9521  
    212212}
    213213
    214 bool PlayerStats::changeNickHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId )
     214bool PlayerStats::changeNickHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId )
    215215{
    216216  std::string newNick;
     
    219219  if ( res != dataLength )
    220220  {
    221     PRINTF(2)("invalid message size from user %d\n", userId);
     221    PRINTF(2)("invalid message size from user %d\n", senderId);
    222222    newNick = "invalid";
    223223  }
    224224
    225   if ( PlayerStats::getStats( userId ) )
    226     PlayerStats::getStats( userId )->setNickName( newNick );
     225  if ( PlayerStats::getStats( senderId) )
     226    PlayerStats::getStats( senderId )->setNickName( newNick );
    227227
    228228  return true;
  • branches/proxy/src/lib/network/player_stats.h

    r9508 r9521  
    6666    inline std::string getNickName(){ return this->nickName; }
    6767    void setNickName( std::string nick );
    68     static bool changeNickHandler( MessageType messageType, byte * data, int dataLength, void * someData, int userId );
     68    static bool changeNickHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId );
    6969    void shellNick( const std::string&  newNick );
    7070
Note: See TracChangeset for help on using the changeset viewer.