Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9522 in orxonox.OLD for branches/proxy/src


Ignore:
Timestamp:
Jul 27, 2006, 8:29:32 PM (18 years ago)
Author:
patrick
Message:

new the message handler is checking, if this message is also for the local host. if not the system tries to relay the message

Location:
branches/proxy/src
Files:
5 edited

Legend:

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

    r9521 r9522  
    227227         outgoingMessageQueue[userId].recievedMessages.end() )
    228228    {
     229
     230//       RT_ALL_BUT_ME = 1,   //!< message is sent to all users but myself
     231//       RT_ALL_ME,           //!< message is sent to all users
     232//       RT_USER,             //!< message is only sent to reciever
     233//       RT_NOT_USER,         //!< message is sent to all but reciever
     234//       RT_SERVER
     235
     236      // find out if this message is addressed for this client too
     237      if( messageType == RT_ALL_BUT_ME ||
     238          messageType == RT_ALL_ME ||
     239          messageType == RT_USER  && SharedNetworkData::getInstance()->getHostID() == destinationId ||
     240          messageType == RT_SERVER && SharedNetworkData::getInstance()->isMasterServer())
     241      {
     242
    229243      // call the handler function and handle errors
    230       if ( !(*(messageHandlerMap[(MessageType)messageType].cb))( (MessageType)messageType, data + i, messageLength,
    231                                                                  messageHandlerMap[(MessageType)messageType].someData, senderId, destinationId ) )
     244        if ( !(*(messageHandlerMap[(MessageType)messageType].cb))( (MessageType)messageType, data + i, messageLength,
     245                 messageHandlerMap[(MessageType)messageType].someData, senderId, destinationId ) )
     246        {
     247        // if the message is not handled correctly, bush it back to the incoming packets
     248          NetworkMessage msg;
     249
     250          msg.data = new byte[messageLength];
     251          memcpy( msg.data, data + i, messageLength );
     252          msg.length = messageLength;
     253          msg.messageType = (MessageType)messageType;
     254          msg.number = userId;
     255          msg.senderId = senderId;
     256          msg.destinationId = destinationId;
     257
     258          incomingMessageQueue.push_back( msg );
     259        }
     260      // save the serial number for ack signaling
     261        outgoingMessageQueue[userId].recievedMessages.push_back( number );
     262        PRINTF(0)("<<< MessageManager: got msg with type: %i, from sender %i, to rec: %i\n", messageType, senderId, destinationId);
     263      }
     264      // or else forward the message to the other servers
     265      else
    232266      {
    233         // if the message is not handled correctly, bush it back to the incoming packets
     267        PRINTF(0)("===========>> Forwarding Message\n");
    234268        NetworkMessage msg;
    235269
     
    244278        incomingMessageQueue.push_back( msg );
    245279      }
    246       // save the serial number for ack signaling
    247       outgoingMessageQueue[userId].recievedMessages.push_back( number );
    248       PRINTF(0)("<<< MessageManager: got msg with type: %i\n", messageType);
    249     }
     280    }
     281
    250282    i += messageLength;
    251283  }
  • branches/proxy/src/lib/network/network_game_manager.cc

    r9521 r9522  
    217217  assert( Converter::intToByteArray( uniqueId, buf, INTSIZE ) == INTSIZE );
    218218
    219   MessageManager::getInstance()->sendMessage( MSGID_DELETESYNCHRONIZEABLE, buf, INTSIZE, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
     219  MessageManager::getInstance()->sendMessage( MSGID_DELETESYNCHRONIZEABLE, buf, INTSIZE, RT_ALL_BUT_ME, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
    220220}
    221221
     
    319319  if ( (SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/) && senderId !=  SharedNetworkData::getInstance()->getHostID() )
    320320  {
    321     MessageManager::getInstance()->sendMessage( messageType, data, dataLength, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
     321    MessageManager::getInstance()->sendMessage( messageType, data, dataLength, RT_ALL_BUT_ME, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
    322322  }
    323323
     
    360360
    361361  if ( SharedNetworkData::getInstance()->isMasterServer() /*|| SharedNetworkData::getInstance()->isProxyServerActive()*/)
    362     MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_ME, 0, MP_HIGHBANDWIDTH );
     362    MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_ME, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
    363363  else
    364     MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
     364    MessageManager::getInstance()->sendMessage( MSGID_CHATMESSAGE, buf, message.length()+3*INTSIZE, RT_ALL_BUT_ME, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
    365365
    366366
  • branches/proxy/src/lib/network/player_stats.cc

    r9521 r9522  
    207207    assert( Converter::stringToByteArray( nick, data, nick.length()+INTSIZE) == nick.length()+INTSIZE );
    208208
    209     MessageManager::getInstance()->sendMessage( MSGID_CHANGENICKNAME, data, nick.length()+INTSIZE, RT_SERVER, 0, MP_HIGHBANDWIDTH );
     209    MessageManager::getInstance()->sendMessage( MSGID_CHANGENICKNAME, data, nick.length()+INTSIZE, RT_SERVER, NET_MASTER_SERVER, MP_HIGHBANDWIDTH );
    210210    return;
    211211  }
  • branches/proxy/src/subprojects/network/network_unit_test.cc

    r9508 r9522  
    5252    server1 = server.getNewSocket();
    5353  }
    54  
     54
    5555  assert( server1->isOk() );
    5656
     
    8686  printf("%d bytes send from server2\n", n);
    8787  SDL_Delay(10);
    88  
     88
    8989  server.update();
    9090
     
    120120
    121121  printf("data: '%s'\n", buf);
    122  
    123  
     122
     123
    124124  //22222222222222222222222222222222222222222
    125125  n = client1->writePacket((byte*)str1, strlen(str1)+1);
     
    132132  printf("%d bytes send from server2\n", n);
    133133  SDL_Delay(10);
    134  
     134
    135135  server.update();
    136136
     
    181181  delete client2;
    182182  delete server1;
    183   delete server2; 
    184  
     183  delete server2;
     184
    185185  return 0;
    186186}
     
    259259
    260260  NetworkManager* netMan = NetworkManager::getInstance();
    261  
     261
    262262  netMan->initialize();
    263  
     263
    264264  netMan->createMasterServer(/**ss, */ 9999);
    265  
     265
    266266  SimpleSync* ss = new SimpleSync("Server");
    267267  ss->setSynchronized( true );
    268  
     268
    269269  NetworkLog::getInstance()->listen( 8888 );
    270270
    271271  //MessageManager::getInstance()->initUser( 1 );
    272272  MessageManager::getInstance()->registerMessageHandler( TESTMESSAGEID, testCB, NULL );
    273  
     273
    274274  SDL_Delay(20);
    275275
    276276  for(;;)
    277277  {
    278     MessageManager::getInstance()->sendMessage( TESTMESSAGEID, (byte*)"server to client", 18, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
     278    MessageManager::getInstance()->sendMessage( TESTMESSAGEID, (byte*)"server to client", 18, RT_ALL_BUT_ME, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
    279279    netMan->synchronize( 100 );
    280280    SDL_Delay(100);
     
    296296  State::setOnline(true);
    297297  NetworkManager* netMan = NetworkManager::getInstance();
    298  
     298
    299299
    300300  netMan->initialize();
    301  
     301
    302302  std::string host;
    303  
     303
    304304  if ( argc > 2 )
    305305    host = argv[2];
    306306  else
    307307    host = "localhost";
    308  
     308
    309309  netMan->createClient(host, 9999);
    310  
     310
    311311//  SimpleSync* ss = new SimpleSync("SimpleSync");
    312312//  ss->setSynchronized( true );
    313313//  netMan->connectSynchronizeable( *ss );
    314  
     314
    315315  NetworkLog::getInstance()->listen( 7777 );
    316316
    317317  SimpleSync * ss = NULL;
    318  
     318
    319319  //MessageManager::getInstance()->initUser( 0 );
    320320  MessageManager::getInstance()->registerMessageHandler( TESTMESSAGEID, testCB, NULL );
    321  
     321
    322322  for(;;)
    323323  {
    324324    netMan->synchronize( 100 );
    325     MessageManager::getInstance()->sendMessage( TESTMESSAGEID, (byte*)"client to server", 18, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
     325    MessageManager::getInstance()->sendMessage( TESTMESSAGEID, (byte*)"client to server", 18, RT_ALL_BUT_ME, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
    326326    ss = dynamic_cast<SimpleSync*>(ClassList::getObject( "Server", CL_SIMPLE_SYNC ) );
    327327    SDL_Delay(100);
  • branches/proxy/src/world_entities/spawning_point.cc

    r9521 r9522  
    213213  assert( Converter::intToByteArray( uniqueId, buf + INTSIZE, INTSIZE ) == INTSIZE );
    214214
    215   MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_BUT_ME, 0, MP_HIGHBANDWIDTH );
     215  MessageManager::getInstance()->sendMessage( MSGID_RESPAWN, buf, 2*INTSIZE, RT_ALL_BUT_ME, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
    216216}
    217217
Note: See TracChangeset for help on using the changeset viewer.