- Timestamp:
- Jul 12, 2006, 10:35:26 AM (18 years ago)
- Location:
- branches/proxy/src/lib/network
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/network/netdefs.h
r9246 r9248 27 27 //!< enum indicating the type of the node 28 28 typedef enum { 29 NET_SERVER, 30 NET_CLIENT 29 NET_MASTER_SERVER, 30 NET_PROXY_SERVER, 31 NET_CLIENT, 32 33 NET_NR_TYPES 34 31 35 } NodeType; 32 36 -
branches/proxy/src/lib/network/network_game_manager.h
r8708 r9248 42 42 43 43 /*! 44 * a class that can create and remove entities 44 * a class that can create and remove entities over the network 45 45 */ 46 46 class NetworkGameManager: public Synchronizeable 47 47 { 48 48 49 public: 49 50 virtual ~NetworkGameManager(); 50 51 51 52 static NetworkGameManager* NetworkGameManager::getInstance() 52 53 { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; } … … 55 56 bool signalNewPlayer( int userId ); 56 57 bool signalLeftPlayer( int userID ); 57 58 void removeSynchronizeable( int uniqueId ); 59 58 60 59 void prefereTeam( int teamId ); 60 61 61 62 62 inline void setGameState( int gameState ){ this->gameState = gameState; } 63 63 inline int getGameState(){ return this->gameState; } 64 64 65 65 void tick( float ds ); 66 66 67 void removeSynchronizeable( int uniqueId ); 67 68 void sendChatMessage( const std::string & message, int messageType ); 69 68 70 69 71 private: 70 72 NetworkGameManager(); 71 73 72 74 static bool delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 73 75 static bool preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 74 76 static bool chatMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId ); 75 77 76 78 void setPreferedTeam( int userId, int teamId ); 77 79 80 81 private: 78 82 static NetworkGameManager* singletonRef; 79 83 80 84 int gameState; 81 85 82 86 std::list<Playable*> playablesToDelete; 83 87 }; -
branches/proxy/src/lib/network/network_stream.cc
r9246 r9248 52 52 53 53 54 /** 55 * empty constructor 56 */ 54 57 NetworkStream::NetworkStream() 55 58 : DataStream() … … 62 65 63 66 /** 64 * connect to a server as a client67 * start as a client, connect to a server 65 68 * @param host: host name (address) 66 69 * @param port: port number … … 83 86 NetworkStream::NetworkStream( int port ) 84 87 { 85 this->type = NET_ SERVER;88 this->type = NET_MASTER_SERVER; 86 89 this->init(); 87 90 this->serverSocket = new UdpServerSocket(port); … … 100 103 this->serverSocket = NULL; 101 104 this->networkGameManager = NULL; 102 myHostId = 0;103 currentState = 0;105 this->myHostId = 0; 106 this->currentState = 0; 104 107 105 108 remainingBytesToWriteToDict = Preferences::getInstance()->getInt( "compression", "writedict", 0 ); … … 373 376 void NetworkStream::debug() 374 377 { 375 if( this->is Server())378 if( this->isMasterServer()) 376 379 PRINT(0)(" Host ist Server with ID: %i\n", this->myHostId); 377 380 else … … 524 527 525 528 // server fakes uniqueid == 0 for handshake 526 if ( this->is Server() && sync.getUniqueID() < MAX_CONNECTIONS - 1 )529 if ( this->isMasterServer() && sync.getUniqueID() < MAX_CONNECTIONS - 1 ) 527 530 n = Converter::intToByteArray( 0, buf + offset, UDP_PACKET_SIZE - offset ); 528 531 else -
branches/proxy/src/lib/network/network_stream.h
r9246 r9248 61 61 void disconnectSynchronizeable(Synchronizeable& sync); 62 62 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; } 64 66 inline bool isActive() const { return this->bActive; } 65 67
Note: See TracChangeset
for help on using the changeset viewer.