Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 8, 2010, 4:25:52 PM (14 years ago)
Author:
dafrick
Message:

Merging masterserver branch to new presentation branch.

Location:
code/branches/presentation
Files:
5 edited
11 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/libraries/network/CMakeLists.txt

    r7490 r7739  
    3232  LANDiscoverable.cc
    3333  LANDiscovery.cc
     34  WANDiscovery.cc
     35  MasterServerComm.cc
    3436  NetworkFunction.cc
    3537  Host.cc
    3638  Server.cc
     39  MasterServer.cc
     40  PeerList.cc
     41  ServerList.cc
    3742  ServerConnection.cc
    3843  TrafficControl.cc
     
    5459  LANDiscoverable.h
    5560  LANDiscovery.h
     61  WANDiscovery.h
     62  MasterServerComm.h
    5663  NetworkFunction.h
    5764  NetworkPrecompiledHeaders.h
    5865  NetworkPrereqs.h
    5966  Server.h
     67  MasterServer.h
     68  PeerList.h
     69  ServerList.h
    6070  ServerConnection.h
    6171  TrafficControl.h
     
    6979    Client.h
    7080    LANDiscovery.h
     81    WANDiscovery.h
    7182  PCH_FILE
    7283    NetworkPrecompiledHeaders.h
  • code/branches/presentation/src/libraries/network/Server.cc

    r7284 r7739  
    9999  }
    100100
     101
     102  /* TODO */
     103  void Server::helper_ConnectToMasterserver()
     104  {
     105    /* initialize it and see if it worked */
     106    if( msc.initialize() )
     107    { COUT(1) << "Error: could not initialize master server communications!\n";
     108      return;
     109    }
     110
     111    /* connect and see if it worked */
     112    if( msc.connect( MS_ADDRESS, 1234 ) )
     113    { COUT(1) << "Error: could not connect to master server!\n";
     114      return;
     115    }
     116
     117    /* now send the master server some note we're here */
     118    msc.sendRequest( MSPROTO_GAME_SERVER " " MSPROTO_REGISTER_SERVER );
     119  }
     120
    101121  /**
    102122  * This function opens the server by creating the listener thread
     
    107127    COUT(4) << "opening server" << endl;
    108128    this->openListener();
     129   
     130    /* make discoverable on LAN */
    109131    LANDiscoverable::setActivity(true);
     132
     133    /* make discoverable on WAN */
     134    helper_ConnectToMasterserver();
     135
     136    /* done */
    110137    return;
    111138  }
     
    140167
    141168
     169  /* TODO */
     170  int rephandler( char *addr, ENetEvent *ev )
     171  {
     172    /* handle incoming data */
     173
     174    /* done handling, return all ok code 0 */
     175    return 0;
     176  }
     177
     178  void Server::helper_HandleMasterServerRequests()
     179  {
     180    this->msc.pollForReply( rephandler );
     181  }
     182
    142183  /**
    143184  * Run this function once every tick
     
    149190    // receive incoming packets
    150191    Connection::processQueue();
     192
    151193    // receive and process incoming discovery packets
    152194    LANDiscoverable::update();
     195
     196    // receive and process requests from master server
     197    helper_HandleMasterServerRequests();
    153198
    154199    if ( ClientInformation::hasClients() )
  • code/branches/presentation/src/libraries/network/Server.h

    r7163 r7739  
    3838#include "ServerConnection.h"
    3939#include "LANDiscoverable.h"
     40#include "MasterServerComm.h"
     41#include "MasterServerProtocol.h"
     42
    4043
    4144namespace orxonox
     
    5255    Server(int port, const std::string& bindAddress);
    5356    ~Server();
     57
     58    /* helpers */
     59    void helper_ConnectToMasterserver();
     60    void helper_HandleMasterServerRequests();
     61    int replyhandler( char *addr, ENetEvent *ev );
    5462
    5563    void open();
     
    8290
    8391    float timeSinceLastUpdate_;
     92    MasterServerComm msc;
    8493  };
    8594
  • code/branches/presentation/src/libraries/network/WANDiscovery.cc

    r7737 r7739  
    4141  ManageScopedSingleton(WANDiscovery, ScopeID::Root, true);
    4242
    43   void WANDiscovery::setConfigValues()
    44   {
    45     SetConfigValue(this->msaddr, "msaddr");
    46   }
    4743
    4844  WANDiscovery::WANDiscovery()
     
    5450    RegisterObject(WANDiscovery);
    5551
    56     /* set default string for this->msaddr */
    57     this->msaddr = "localhost";
    58 
    5952    /* ... and register a config value function for it */
    6053    this->setConfigValues();
     
    6558
    6659    /* connect and see if it worked */
    67     if( msc.connect( this->msaddr.c_str(), 1234 ) )
     60    if( msc.connect( this->msaddress.c_str(), 1234 ) )
    6861      COUT(2) << "Error: could not connect to master server at "
    69         << this->msaddr << std::endl;
     62        << this->msaddress << std::endl;
    7063
    7164    /* debugging output */
    7265    COUT(4) << "Initialization of WANDiscovery complete.\n";
    7366  }
     67
     68  void WANDiscovery::setConfigValues()
     69  {
     70    SetConfigValue( msaddress, "localhost");
     71  }
    7472
    7573  WANDiscovery::~WANDiscovery()
  • code/branches/presentation/src/libraries/network/WANDiscovery.h

    r7737 r7739  
    100100
    101101      /** master server address */
    102       std::string msaddr;
     102      std::string msaddress;
    103103
    104104  }; // tolua_export
  • code/branches/presentation/src/libraries/network/packet/ServerInformation.h

    r7459 r7739  
    5050        std::string   getServerName() { return this->serverName_; }
    5151        void          setServerName(std::string name) { this->serverName_ = name; }
     52        void          setServerIP( std::string IP ) { this->serverIP_ = IP; }
    5253        uint32_t      getServerRTT() { return this->serverRTT_; }
    5354       
Note: See TracChangeset for help on using the changeset viewer.