Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8832


Ignore:
Timestamp:
Aug 9, 2011, 12:37:21 AM (13 years ago)
Author:
landauf
Message:

Quick and dirty fix to un-singletonize WANDiscovery. It is now created on demand by the multiplayer menu. This delays the master server connection until we really need it (and avoids the annoying connection-failed error/warning during startup if the master server can't be reached).
Also removed some unneeded/commented functions related to WANDiscovery from Server.
Presumably won't collide with the changes in the masterserver2 branch, but needs some review.

Location:
code/branches/output
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/output/data/gui/scripts/MultiplayerMenu.lua

    r8079 r8832  
    117117        local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
    118118        CEGUI.toListbox(listbox):resetList()
    119         local discovery = orxonox.WANDiscovery:getInstance()
     119        local discovery = orxonox.WANDiscovery()
    120120        cout(0, "discovering.\n" )
    121121        discovery:discover()
  • code/branches/output/src/libraries/network/MasterServerComm.cc

    r8807 r8832  
    2929#include "MasterServerComm.h"
    3030#include "util/Output.h"
     31#include "WANDiscovery.h"
    3132
    3233namespace orxonox
     
    149150   * so we can also make callbacks from objects
    150151   */
    151   int MasterServerComm::pollForReply( int (*callback)( char*, ENetEvent* ),
    152     int delayms )
     152  int MasterServerComm::pollForReply( WANDiscovery* listener, int delayms )
    153153  {
    154154    /* see whether anything happened */
     
    193193
    194194          /* call the supplied callback, if any. */
    195           if( (*callback) != NULL )
    196             retval = (*callback)( addrconv, &(this->event) );
     195          if( listener != NULL )
     196            retval = listener->rhandler( addrconv, &(this->event) );
    197197
    198198          /* clean up */
  • code/branches/output/src/libraries/network/MasterServerComm.h

    r8351 r8832  
    9393       *
    9494       * Poll the master server for new data and act accordingly */
    95       int pollForReply( int (*callback)( char*, ENetEvent* ), int delayms );
     95      int pollForReply( WANDiscovery* listener, int delayms );
    9696
    9797    private:
  • code/branches/output/src/libraries/network/NetworkPrereqs.h

    r8829 r8832  
    129129  class GamestateManager;
    130130  class Host;
     131  class MasterServer;
     132  class MasterServerComm;
    131133  class NetworkChatListener;
    132134  class NetworkFunctionBase;
     
    136138  class NetworkMemberFunction;
    137139  class NetworkMemberFunctionBase;
     140  class PeerList;
    138141  class Server;
    139142  class ServerConnection;
    140143  class TrafficControl;
     144  class WANDiscoverable;
     145  class WANDiscovery;
    141146
    142147  // packet
  • code/branches/output/src/libraries/network/Server.cc

    r8829 r8832  
    5959#include "FunctionCallManager.h"
    6060#include "GamestateManager.h"
    61 #include "WANDiscovery.h"
    6261
    6362namespace orxonox
     
    9998  }
    10099
    101 
    102   /** helper that connects to the master server */
    103   void Server::helper_ConnectToMasterserver()
    104   {
    105 //     WANDiscovery::getInstance().msc.sendRequest( MSPROTO_GAME_SERVER " "
    106 //       MSPROTO_REGISTER_SERVER );
    107   }
    108 
    109100  /**
    110101  * This function opens the server by creating the listener thread
     
    121112    /* make discoverable on WAN */
    122113    WANDiscoverable::setActivity(true);
    123     /* TODO this needs to be optional, we need a switch from the UI to
    124      * enable/disable this
    125      */
    126 //     helper_ConnectToMasterserver();
    127114
    128115    /* done */
     
    149136  }
    150137
    151   /* handle incoming data */
    152   int rephandler( char *addr, ENetEvent *ev )
    153   {
    154     /* reply to pings */
    155     if( !strncmp( (char *)ev->packet->data, MSPROTO_PING_GAMESERVER,
    156       MSPROTO_PING_GAMESERVER_LEN ) )
    157       //this->msc.sendRequest( MSPROTO_ACK );
    158       /* NOTE implement this after pollForReply
    159        * reimplementation
    160        */
    161       return 0;
    162 
    163     /* done handling, return all ok code 0 */
    164     return 0;
    165   }
    166 
    167   void Server::helper_HandleMasterServerRequests()
    168   {
    169     /* poll the master server for replies and see whether something
    170      * has to be done or changed.
    171      */
    172     //WANDiscovery::getInstance().msc.pollForReply( rhandler, 10 );
    173   }
    174 
    175138  /**
    176139  * Run this function once every tick
     
    185148    // receive and process incoming discovery packets
    186149    LANDiscoverable::update();
    187 
    188     // receive and process requests from master server
    189     /* todo */
    190     //helper_HandleMasterServerRequests();
    191150
    192151    if ( GamestateManager::hasPeers() )
  • code/branches/output/src/libraries/network/Server.h

    r8829 r8832  
    4242#include "LANDiscoverable.h"
    4343#include "WANDiscoverable.h"
    44 // #include "MasterServerComm.h"
    45 // #include "MasterServerProtocol.h"
    4644
    4745
     
    6058    Server(int port, const std::string& bindAddress);
    6159    ~Server();
    62 
    63     /* helpers */
    64     void helper_ConnectToMasterserver();
    65     void helper_HandleMasterServerRequests();
    66     int replyhandler( char *addr, ENetEvent *ev );
    6760
    6861    void open();
  • code/branches/output/src/libraries/network/WANDiscovery.cc

    r8817 r8832  
    3232#include <cstring>
    3333
    34 #include "util/ScopedSingletonManager.h"
    3534#include "core/CoreIncludes.h"
    3635
     
    3837namespace orxonox
    3938{
    40   ManageScopedSingleton(WANDiscovery, ScopeID::Graphics, true);
    41 
    42 
    4339  WANDiscovery::WANDiscovery()
    4440  {
     
    8076
    8177  /* callback for the network reply poller */
    82   int rhandler( char *addr, ENetEvent *ev )
     78  int WANDiscovery::rhandler( char *addr, ENetEvent *ev )
    8379  {
    8480    /* error recognition */
     
    10399
    104100      /* add to list */
    105       WANDiscovery::getInstance().servers_.push_back( toadd );
     101      this->servers_.push_back( toadd );
    106102    }
    107103    else if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_END,
     
    132128    {
    133129      /* poll for reply and act according to what was received */
    134       switch( this->msc.pollForReply( rhandler, 500 ) )
     130      switch( this->msc.pollForReply( this, 500 ) )
    135131      { case 0: /* no event occured, decrease timeout */
    136132          --i; break;
  • code/branches/output/src/libraries/network/WANDiscovery.h

    r8817 r8832  
    3232#include "packet/ServerInformation.h"
    3333#include "core/ConfigFileManager.h"
    34 #include "util/Singleton.h"
    3534#include "core/OrxonoxClass.h"
    3635#include "core/ConfigValueIncludes.h"
     
    4948  class _NetworkExport WANDiscovery
    5049// tolua_end
    51     : public Singleton<WANDiscovery>, public OrxonoxClass
     50    : public OrxonoxClass
    5251  { // tolua_export
    53     friend class Singleton<WANDiscovery>;
    5452    public:
    5553      /** constructor */
    56       WANDiscovery();
     54      WANDiscovery(); // tolua_export
    5755
    5856      /** destructor */
     
    8381      std::string getServerListItemIP( unsigned int index ); // tolua_export
    8482
    85       /** \return an instance of WANDiscovery
    86        *
    87        * Create and return an instance of WANDiscovery.
    88        */
    89       static WANDiscovery& getInstance() { return Singleton<WANDiscovery>::getInstance(); } // tolua_export
    90    
    9183      /* todo: might make this private and use getter/setter methods
    9284       * at some later time.
     
    10092      /** Master server communications object */
    10193      MasterServerComm msc;
     94
     95      int rhandler( char *addr, ENetEvent *ev );
    10296     
    10397    private:
    104       /** Singleton pointer */
    105       static WANDiscovery* singletonPtr_s;
    106 
    10798      /** master server address */
    10899      std::string msaddress;
Note: See TracChangeset for help on using the changeset viewer.