Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9570 in orxonox.OLD for branches


Ignore:
Timestamp:
Jul 28, 2006, 3:21:22 PM (18 years ago)
Author:
patrick
Message:

disconnecting client over the network via proxy control

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

Legend:

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

    r9563 r9570  
    3636  MSGID_RESPAWN,                              //!< respawn message
    3737
    38   MSGID_PROXY_NEWCLIENT                        //!< informs the master server about a new client
     38  MSGID_PROXY_NEWCLIENT,                       //!< informs the master server about a new client
     39  MSGID_PROXY_LEAVECLIENT                      //!< informs the master and other proxy servers about a leaving client
    3940};
    4041
  • branches/proxy/src/lib/network/network_stream.cc

    r9564 r9570  
    453453
    454454
     455
    455456  //check if connections are ok else remove them
    456457  for ( PeerList::iterator it = peers.begin(); it != peers.end(); )
     
    470471
    471472      this->handleDisconnect( it->second.userId);
     473      if( SharedNetworkData::getInstance()->isProxyServerActive())
     474        ProxyControl::getInstance()->signalLeaveClient(it->second.userId);
    472475
    473476      it++;
  • branches/proxy/src/lib/network/proxy/proxy_control.cc

    r9557 r9570  
    128128  return true;
    129129}
     130
     131
     132
     133/**
     134 *  signals client disconnect
     135 * @param userId userId of the old client
     136 */
     137void ProxyControl::signalLeaveClient(int userId)
     138{
     139  PRINTF(0)("Signaling new Client: %i\n", userId);
     140  // make sure we are a proxy server
     141  assert(SharedNetworkData::getInstance()->isProxyServerActive());
     142
     143  byte data[INTSIZE];
     144
     145  assert( Converter::intToByteArray( userId, data, INTSIZE ) == INTSIZE );
     146
     147  MessageManager::getInstance()->sendMessage( MSGID_PROXY_LEAVECLIENT, data, INTSIZE, RT_SERVER, NET_UNASSIGNED, MP_HIGHBANDWIDTH );
     148}
     149
     150
     151/**
     152 * this is the handler for proxy signals: removing clients
     153 *
     154 * @param messageType the type of the message
     155 * @param data message data
     156 * @param dataLength length of the message data
     157 * @param someData some other atteched data
     158 * @param senderId id of the sender client
     159 * @param destinationId id of the destination client
     160 * @return true if succeeded
     161 */
     162bool ProxyControl::messageHandlerLeaveClient( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId  )
     163{
     164  // body data length correct?
     165  if ( dataLength != INTSIZE )
     166  {
     167    PRINTF(2)("leave client message has wrong size: %d\n", dataLength );
     168    return true;
     169  }
     170  // read the userId fromt he message body
     171  int leaveClientId = 0;
     172  assert( Converter::byteArrayToInt( data, &leaveClientId) == INTSIZE );
     173
     174  PRINTF(0)("Got Signal: from %i new player left with userId: %i\n", senderId, leaveClientId);
     175  // part for the master server
     176  if( SharedNetworkData::getInstance()->isMasterServer())
     177  {
     178    // we now create the new player ship and stuff...
     179    NetworkGameManager::getInstance()->signalNewPlayer(leaveClientId);
     180  }
     181  else if(SharedNetworkData::getInstance()->isProxyServerActive())
     182  {
     183
     184  }
     185
     186  return true;
     187}
  • branches/proxy/src/lib/network/proxy/proxy_control.h

    r9538 r9570  
    3131    static bool messageHandlerNewClient( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId  );
    3232
     33    void signalLeaveClient(int userId);
     34    static bool messageHandlerLeaveClient( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId  );
     35
    3336
    3437  private:
Note: See TracChangeset for help on using the changeset viewer.