[Orxonox-commit 2934] r7634 - code/branches/masterserver/src/libraries/network

smerkli at orxonox.net smerkli at orxonox.net
Wed Nov 10 16:22:58 CET 2010


Author: smerkli
Date: 2010-11-10 16:22:58 +0100 (Wed, 10 Nov 2010)
New Revision: 7634

Modified:
   code/branches/masterserver/src/libraries/network/Server.cc
   code/branches/masterserver/src/libraries/network/Server.h
Log:


Modified: code/branches/masterserver/src/libraries/network/Server.cc
===================================================================
--- code/branches/masterserver/src/libraries/network/Server.cc	2010-11-10 15:01:07 UTC (rev 7633)
+++ code/branches/masterserver/src/libraries/network/Server.cc	2010-11-10 15:22:58 UTC (rev 7634)
@@ -100,9 +100,18 @@
 
 
   /* TODO */
-  void helper_ConnectToMasterserver()
+  void Server::helper_ConnectToMasterserver()
   {
-    /* TODO connect to master server here and say you're there */
+    /* initialize it and see if it worked */
+    if( msc.initialize() )
+      COUT(1) << "Error: could not initialize master server communications!\n";
+
+    /* connect and see if it worked */
+    if( msc.connect( MS_ADDRESS, 1234 ) )
+      COUT(1) << "Error: could not connect to master server!\n";
+
+    /* TODO */
+    /* now send the master server some note we're here */
   }
 
   /**
@@ -153,6 +162,20 @@
   }
 
 
+  /* TODO */
+  int replyhandler( char *addr, ENetEvent *ev )
+  { 
+    /* handle incoming data */
+
+    /* done handling, return all ok code 0 */
+    return 0;
+  }
+
+  void Server::helper_HandleMasterServerRequests()
+  { 
+    this->msc.pollForReply( replyhandler ); 
+  }
+
   /**
   * Run this function once every tick
   * calls processQueue and updateGamestate
@@ -166,7 +189,8 @@
     // receive and process incoming discovery packets
     LANDiscoverable::update();
 
-    // TODO receive and process requests from master server
+    // receive and process requests from master server
+    helper_HandleMasterServerRequests();
 
     if ( ClientInformation::hasClients() )
     {

Modified: code/branches/masterserver/src/libraries/network/Server.h
===================================================================
--- code/branches/masterserver/src/libraries/network/Server.h	2010-11-10 15:01:07 UTC (rev 7633)
+++ code/branches/masterserver/src/libraries/network/Server.h	2010-11-10 15:22:58 UTC (rev 7634)
@@ -37,7 +37,11 @@
 #include "GamestateManager.h"
 #include "ServerConnection.h"
 #include "LANDiscoverable.h"
+#include "MasterServerComm.h"
 
+/* proto (move to central point soon) */ 
+#define MS_ADDRESS "localhost"
+
 namespace orxonox
 {
 
@@ -52,6 +56,7 @@
     Server(int port, const std::string& bindAddress);
     ~Server();
 
+    void helper_ConnectToMasterserver();
     void open();
     void close();
     bool processChat(const std::string& message, unsigned int playerID);
@@ -81,6 +86,7 @@
     void syncClassid(unsigned int clientID);
 
     float timeSinceLastUpdate_;
+    MasterServerComm msc;
   };
 
 




More information about the Orxonox-commit mailing list