[Orxonox-commit 3047] r7743 - in code/branches/presentation/src: libraries/network orxonox orxonox/gamestates

smerkli at orxonox.net smerkli at orxonox.net
Wed Dec 8 17:13:03 CET 2010


Author: smerkli
Date: 2010-12-08 17:13:03 +0100 (Wed, 08 Dec 2010)
New Revision: 7743

Modified:
   code/branches/presentation/src/libraries/network/MasterServer.cc
   code/branches/presentation/src/orxonox/Main.cc
   code/branches/presentation/src/orxonox/gamestates/GSMasterServer.cc
Log:
made mastserserver mode non-blocking

Modified: code/branches/presentation/src/libraries/network/MasterServer.cc
===================================================================
--- code/branches/presentation/src/libraries/network/MasterServer.cc	2010-12-08 16:04:15 UTC (rev 7742)
+++ code/branches/presentation/src/libraries/network/MasterServer.cc	2010-12-08 16:13:03 UTC (rev 7743)
@@ -219,29 +219,23 @@
       exit( EXIT_FAILURE );
     }
 
-    /* tell people we're now initialized and blocking. */
-    COUT(0) << "MasterServer initialized, waiting for connections.\n";
     
-    /* endless loop until we quit */
-    while( this->quit == false )
-    {
-      /* create an iterator for the loop */
-      while( enet_host_service( this->server, event, 1000 ) >= 0 )
-      { /* check what type of event it is and react accordingly */
-        switch (event->type)
-        { /* new connection */
-          case ENET_EVENT_TYPE_CONNECT: 
-            eventConnect( event ); break;
+    /* create an iterator for the loop */
+    enet_host_service( this->server, event, 100 );
 
-            /* disconnect */
-          case ENET_EVENT_TYPE_DISCONNECT: 
-            eventDisconnect( event ); break;
+    /* check what type of event it is and react accordingly */
+    switch (event->type)
+    { /* new connection */
+      case ENET_EVENT_TYPE_CONNECT: 
+        eventConnect( event ); break;
 
-            /* incoming data */
-          case ENET_EVENT_TYPE_RECEIVE: eventData( event ); break;
-          default: break;
-        }
-      }
+        /* disconnect */
+      case ENET_EVENT_TYPE_DISCONNECT: 
+        eventDisconnect( event ); break;
+
+        /* incoming data */
+      case ENET_EVENT_TYPE_RECEIVE: eventData( event ); break;
+      default: break;
     }
 
     /* done */
@@ -282,6 +276,9 @@
     /***** INITIALIZE GAME SERVER AND PEER LISTS *****/
     //this->mainlist = new ServerList();
     this->peers = new PeerList();
+
+    /* tell people we're now initialized */
+    COUT(0) << "MasterServer initialized, waiting for connections.\n";
   }
 
   /* destructor */

Modified: code/branches/presentation/src/orxonox/Main.cc
===================================================================
--- code/branches/presentation/src/orxonox/Main.cc	2010-12-08 16:04:15 UTC (rev 7742)
+++ code/branches/presentation/src/orxonox/Main.cc	2010-12-08 16:13:03 UTC (rev 7743)
@@ -76,7 +76,7 @@
             "  mainMenu"
             "  standalone,server,client"
             "   level"
-            " server,client"
+            " server,client,masterserver"
             "  level"
             );
 

Modified: code/branches/presentation/src/orxonox/gamestates/GSMasterServer.cc
===================================================================
--- code/branches/presentation/src/orxonox/gamestates/GSMasterServer.cc	2010-12-08 16:04:15 UTC (rev 7742)
+++ code/branches/presentation/src/orxonox/gamestates/GSMasterServer.cc	2010-12-08 16:13:03 UTC (rev 7743)
@@ -62,5 +62,7 @@
   { /* nothing so far */ }
 
   void GSMasterServer::update(const Clock& time)
-  { /* nothing so far */ }
+  { 
+    this->mserver->run();
+  }
 }




More information about the Orxonox-commit mailing list