[Orxonox-commit 550] r3093 - trunk/src/network

scheusso at orxonox.net scheusso at orxonox.net
Wed May 27 21:39:38 CEST 2009


Author: scheusso
Date: 2009-05-27 21:39:38 +0200 (Wed, 27 May 2009)
New Revision: 3093

Modified:
   trunk/src/network/ConnectionManager.cc
   trunk/src/network/ConnectionManager.h
Log:
it is now possible to send packets/network function calls to all clients by passing CLIENTID_UNKNOWN as clientID


Modified: trunk/src/network/ConnectionManager.cc
===================================================================
--- trunk/src/network/ConnectionManager.cc	2009-05-27 19:37:12 UTC (rev 3092)
+++ trunk/src/network/ConnectionManager.cc	2009-05-27 19:39:38 UTC (rev 3093)
@@ -142,24 +142,32 @@
     return true;
   }
 
-  bool ConnectionManager::addPacket(ENetPacket *packet, int clientID) {
-    ClientInformation *temp = ClientInformation::findClient(clientID);
-    if(!temp){
-      COUT(3) << "C.Man: addPacket findClient failed" << std::endl;
-      return false;
+  bool ConnectionManager::addPacket(ENetPacket *packet, unsigned int clientID) {
+    if ( clientID == CLIENTID_UNKNOWN )
+    {
+      return addPacketAll(packet);
     }
-    return addPacket(packet, temp->getPeer());
+    else
+    {
+      ClientInformation *temp = ClientInformation::findClient(clientID);
+      if(!temp){
+        COUT(3) << "C.Man: addPacket findClient failed" << std::endl;
+        return false;
+      }
+      return addPacket(packet, temp->getPeer());
+    }
   }
 
   bool ConnectionManager::addPacketAll(ENetPacket *packet) {
     if(!instance_)
       return false;
     boost::recursive_mutex::scoped_lock lock(enet_mutex_g);
-    for(ClientInformation *i=ClientInformation::getBegin()->next(); i!=0; i=i->next()){
-      COUT(3) << "adding broadcast packet for client: " << i->getID() << std::endl;
-      if(enet_peer_send(i->getPeer(), 0, packet)!=0)
-        return false;
-    }
+//    for(ClientInformation *i=ClientInformation::getBegin()->next(); i!=0; i=i->next()){
+//      COUT(3) << "adding broadcast packet for client: " << i->getID() << std::endl;
+//      if(enet_peer_send(i->getPeer(), 0, packet)!=0)
+//        return false;
+//    }
+    enet_host_broadcast( instance_->server, 0, packet);
     return true;
   }
 

Modified: trunk/src/network/ConnectionManager.h
===================================================================
--- trunk/src/network/ConnectionManager.h	2009-05-27 19:37:12 UTC (rev 3092)
+++ trunk/src/network/ConnectionManager.h	2009-05-27 19:39:38 UTC (rev 3093)
@@ -75,7 +75,7 @@
     void createListener();
     bool quitListener();
     static bool addPacket(ENetPacket *packet, ENetPeer *peer);
-    static bool addPacket(ENetPacket *packet, int ID);
+    static bool addPacket(ENetPacket *packet, unsigned int ID);
     static bool addPacketAll(ENetPacket *packet);
     bool sendPackets();
     void disconnectClient(ClientInformation *client);




More information about the Orxonox-commit mailing list