[Orxonox-commit 2974] r7672 - code/branches/masterserver/src/libraries/network

smerkli at orxonox.net smerkli at orxonox.net
Wed Nov 24 23:12:31 CET 2010


Author: smerkli
Date: 2010-11-24 23:12:30 +0100 (Wed, 24 Nov 2010)
New Revision: 7672

Modified:
   code/branches/masterserver/src/libraries/network/MasterServerComm.cc
   code/branches/masterserver/src/libraries/network/WANDiscovery.cc
   code/branches/masterserver/src/libraries/network/WANDiscovery.h
Log:
just added some notes so I understand my own stuff next week.

Modified: code/branches/masterserver/src/libraries/network/MasterServerComm.cc
===================================================================
--- code/branches/masterserver/src/libraries/network/MasterServerComm.cc	2010-11-24 20:47:57 UTC (rev 7671)
+++ code/branches/masterserver/src/libraries/network/MasterServerComm.cc	2010-11-24 22:12:30 UTC (rev 7672)
@@ -108,7 +108,9 @@
     /* WORK MARK REMOVE THIS OUTPUT */
     COUT(2) << "MARK polling...\n";
 
-    if( enet_host_service( this->client, &this->event, 1000 ) >= 0 )
+    /* enet_host_service returns 0 if no event occured */
+    /* just newly set below test to >0 from >= 0, to be tested */
+    if( enet_host_service( this->client, &this->event, 1000 ) > 0 )
     { 
       /* address buffer */
       char *addrconv = NULL;

Modified: code/branches/masterserver/src/libraries/network/WANDiscovery.cc
===================================================================
--- code/branches/masterserver/src/libraries/network/WANDiscovery.cc	2010-11-24 20:47:57 UTC (rev 7671)
+++ code/branches/masterserver/src/libraries/network/WANDiscovery.cc	2010-11-24 22:12:30 UTC (rev 7672)
@@ -42,19 +42,17 @@
 
   WANDiscovery::WANDiscovery()
   {
-    COUT(0) << "WANDiscovery created.\n";
-    /* create master server communications object */
-    //this->msc = MasterServerComm();
+    COUT(4) << "Creating WANDiscovery.\n";
 
     /* initialize it and see if it worked */
     if( msc.initialize() )
-      COUT(0) << "Error: could not initialize master server communications!\n";
+      COUT(2) << "Error: could not initialize master server communications!\n";
 
     /* connect and see if it worked */
     if( msc.connect( MS_ADDRESS, 1234 ) )
-      COUT(0) << "Error: could not connect to master server!\n";
+      COUT(2) << "Error: could not connect to master server!\n";
 
-    COUT(0) << "Initialization of WANDiscovery complete.\n";
+    COUT(4) << "Initialization of WANDiscovery complete.\n";
   }
 
   WANDiscovery::~WANDiscovery()
@@ -91,7 +89,13 @@
     }
     else if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_END,
       MSPROTO_SERVERLIST_END_LEN ) )
-    { return 1; }
+    { 
+      /* this is the only case where 1 should be returned,
+       * as 1 is used to signal that we're done receiving
+       * the list
+       */
+      return 1; 
+    }
 
     /* done handling, return all ok code 0 */
     return 0;
@@ -105,7 +109,8 @@
     /* send request to server */
     this->msc.sendRequest( MSPROTO_CLIENT " " MSPROTO_REQ_LIST );
 
-    /* deal with replies */
+    /* poll for replies */
+    /* TODO add some timeout here so we don't wait indefinitely */
     while( !((this->msc).pollForReply( rhandler )) )
       /* nothing */;
 

Modified: code/branches/masterserver/src/libraries/network/WANDiscovery.h
===================================================================
--- code/branches/masterserver/src/libraries/network/WANDiscovery.h	2010-11-24 20:47:57 UTC (rev 7671)
+++ code/branches/masterserver/src/libraries/network/WANDiscovery.h	2010-11-24 22:12:30 UTC (rev 7672)
@@ -77,6 +77,9 @@
        */
       static WANDiscovery& getInstance() { return Singleton<WANDiscovery>::getInstance(); } // tolua_export
     
+      /* todo: might make this private and use getter/setter methods
+       * at some later time. 
+       */
       /** game server list */
       std::vector<packet::ServerInformation> servers_;
       




More information about the Orxonox-commit mailing list