Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9248 in orxonox.OLD for branches


Ignore:
Timestamp:
Jul 12, 2006, 10:35:26 AM (18 years ago)
Author:
patrick
Message:

starting switch to multiple server states (proxy, master, client,..)

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

Legend:

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

    r9246 r9248  
    2727//!< enum indicating the type of the node
    2828typedef enum {
    29   NET_SERVER,
    30   NET_CLIENT
     29  NET_MASTER_SERVER,
     30  NET_PROXY_SERVER,
     31  NET_CLIENT,
     32
     33  NET_NR_TYPES
     34
    3135} NodeType;
    3236
  • branches/proxy/src/lib/network/network_game_manager.h

    r8708 r9248  
    4242
    4343/*!
    44  * a class that can create and remove entities
     44 * a class that can create and remove entities over the network
    4545 */
    4646class NetworkGameManager: public Synchronizeable
    4747{
     48
    4849  public:
    4950    virtual ~NetworkGameManager();
    50    
     51
    5152    static NetworkGameManager* NetworkGameManager::getInstance()
    5253    { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; }
     
    5556    bool signalNewPlayer( int userId );
    5657    bool signalLeftPlayer( int userID );
    57    
    58     void removeSynchronizeable( int uniqueId );
    59    
     58
    6059    void prefereTeam( int teamId );
     60
    6161
    6262    inline void setGameState( int gameState ){ this->gameState = gameState; }
    6363    inline int getGameState(){ return this->gameState; }
    64    
     64
    6565    void tick( float ds );
    66    
     66
     67    void removeSynchronizeable( int uniqueId );
    6768    void sendChatMessage( const std::string & message, int messageType );
     69
    6870
    6971  private:
    7072    NetworkGameManager();
    71    
     73
    7274    static bool delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
    7375    static bool preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
    7476    static bool chatMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
    75    
     77
    7678    void setPreferedTeam( int userId, int teamId );
    7779
     80
     81  private:
    7882    static NetworkGameManager*    singletonRef;
    79    
     83
    8084    int                           gameState;
    81    
     85
    8286    std::list<Playable*>          playablesToDelete;
    8387};
  • branches/proxy/src/lib/network/network_stream.cc

    r9246 r9248  
    5252
    5353
     54/**
     55 * empty constructor
     56 */
    5457NetworkStream::NetworkStream()
    5558    : DataStream()
     
    6265
    6366/**
    64  * connect to a server as a client
     67 * start as a client, connect to a server
    6568 *  @param host: host name (address)
    6669 *  @param port: port number
     
    8386NetworkStream::NetworkStream( int port )
    8487{
    85   this->type = NET_SERVER;
     88  this->type = NET_MASTER_SERVER;
    8689  this->init();
    8790  this->serverSocket = new UdpServerSocket(port);
     
    100103  this->serverSocket = NULL;
    101104  this->networkGameManager = NULL;
    102   myHostId = 0;
    103   currentState = 0;
     105  this->myHostId = 0;
     106  this->currentState = 0;
    104107
    105108  remainingBytesToWriteToDict = Preferences::getInstance()->getInt( "compression", "writedict", 0 );
     
    373376void NetworkStream::debug()
    374377{
    375   if( this->isServer())
     378  if( this->isMasterServer())
    376379    PRINT(0)(" Host ist Server with ID: %i\n", this->myHostId);
    377380  else
     
    524527
    525528      // server fakes uniqueid == 0 for handshake
    526       if ( this->isServer() && sync.getUniqueID() < MAX_CONNECTIONS - 1 )
     529      if ( this->isMasterServer() && sync.getUniqueID() < MAX_CONNECTIONS - 1 )
    527530        n = Converter::intToByteArray( 0, buf + offset, UDP_PACKET_SIZE - offset );
    528531      else
  • branches/proxy/src/lib/network/network_stream.h

    r9246 r9248  
    6161    void disconnectSynchronizeable(Synchronizeable& sync);
    6262
    63     inline bool isServer() const { return (this->type == NET_SERVER)? true:false; }
     63    inline bool isMasterServer() const { return (this->type == NET_MASTER_SERVER)? true:false; }
     64    inline bool isProxyServer() const { return (this->type == NET_PROXY_SERVER)? true:false; }
     65    inline bool isClient() const { return (this->type == NET_CLIENT)? true:false; }
    6466    inline bool isActive() const { return this->bActive; }
    6567
Note: See TracChangeset for help on using the changeset viewer.