Changeset 5820 for code/branches/core5/src/libraries
- Timestamp:
- Sep 28, 2009, 2:55:47 AM (15 years ago)
- Location:
- code/branches/core5/src/libraries/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/network/ClientConnectionListener.cc
r5738 r5820 33 33 #include "ClientInformation.h" 34 34 35 namespace orxonox{ 35 namespace orxonox 36 { 37 ClientConnectionListener::ClientConnectionListener() 38 { 39 RegisterRootObject(ClientConnectionListener); 40 } 36 41 37 ClientConnectionListener::ClientConnectionListener() 38 { 39 RegisterRootObject(ClientConnectionListener); 40 } 42 void ClientConnectionListener::broadcastClientConnected(unsigned int clientID) 43 { 44 for (ObjectList<ClientConnectionListener>::iterator it = ObjectList<ClientConnectionListener>::begin(); it != ObjectList<ClientConnectionListener>::end(); ++it) 45 it->clientConnected(clientID); 46 } 47 48 void ClientConnectionListener::broadcastClientDisconnected(unsigned int clientID) 49 { 50 for (ObjectList<ClientConnectionListener>::iterator it = ObjectList<ClientConnectionListener>::begin(); it != ObjectList<ClientConnectionListener>::end(); ++it) 51 it->clientDisconnected(clientID); 52 } 41 53 42 void ClientConnectionListener::getConnectedClients(){ 43 if(GameMode::showsGraphics()) 44 this->clientConnected(0); //server client id 45 ClientInformation *client = ClientInformation::getBegin(); 46 while(client){ 47 this->clientConnected(client->getID()); 48 client=client->next(); 54 void ClientConnectionListener::getConnectedClients() 55 { 56 ClientInformation* client = ClientInformation::getBegin(); 57 while (client) 58 { 59 this->clientConnected(client->getID()); 60 client = client->next(); 61 } 49 62 } 50 }51 52 63 } 53 64 -
code/branches/core5/src/libraries/network/ClientConnectionListener.h
r5738 r5820 33 33 #include "core/OrxonoxClass.h" 34 34 35 namespace orxonox{ 35 namespace orxonox 36 { 37 class _NetworkExport ClientConnectionListener : virtual public OrxonoxClass 38 { 39 public: 40 ClientConnectionListener(); 41 virtual ~ClientConnectionListener() {} 42 43 static void broadcastClientConnected(unsigned int clientID); 44 static void broadcastClientDisconnected(unsigned int clientID); 36 45 37 class _NetworkExport ClientConnectionListener : virtual public OrxonoxClass 38 { 39 friend class Server; 46 virtual void clientConnected(unsigned int clientID) = 0; 47 virtual void clientDisconnected(unsigned int clientID) = 0; 40 48 41 public: 42 ClientConnectionListener(); 43 virtual ~ClientConnectionListener() {} 44 45 void getConnectedClients(); 46 47 protected: 48 virtual void clientConnected(unsigned int clientID) = 0; 49 virtual void clientDisconnected(unsigned int clientID) = 0; 50 }; 51 49 protected: 50 void getConnectedClients(); 51 }; 52 52 } 53 53 -
code/branches/core5/src/libraries/network/Server.cc
r5749 r5820 279 279 280 280 // inform all the listeners 281 ObjectList<ClientConnectionListener>::iterator listener = ObjectList<ClientConnectionListener>::begin(); 282 while(listener){ 283 listener->clientConnected(newid); 284 listener++; 285 } 281 ClientConnectionListener::broadcastClientConnected(newid); 286 282 287 283 ++newid; … … 329 325 ServerConnection::disconnectClient( client ); 330 326 GamestateManager::removeClient(client); 331 // inform all the listeners 332 ObjectList<ClientConnectionListener>::iterator listener = ObjectList<ClientConnectionListener>::begin(); 333 while(listener){ 334 listener->clientDisconnected(client->getID()); 335 ++listener; 336 } 327 // inform all the listeners 328 ClientConnectionListener::broadcastClientDisconnected(client->getID()); 329 337 330 delete client; //remove client from list 338 331 }
Note: See TracChangeset
for help on using the changeset viewer.