Changeset 8832 for code/branches/output/src
- Timestamp:
- Aug 9, 2011, 12:37:21 AM (13 years ago)
- Location:
- code/branches/output/src/libraries/network
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/output/src/libraries/network/MasterServerComm.cc
r8807 r8832 29 29 #include "MasterServerComm.h" 30 30 #include "util/Output.h" 31 #include "WANDiscovery.h" 31 32 32 33 namespace orxonox … … 149 150 * so we can also make callbacks from objects 150 151 */ 151 int MasterServerComm::pollForReply( int (*callback)( char*, ENetEvent* ), 152 int delayms ) 152 int MasterServerComm::pollForReply( WANDiscovery* listener, int delayms ) 153 153 { 154 154 /* see whether anything happened */ … … 193 193 194 194 /* 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) ); 197 197 198 198 /* clean up */ -
code/branches/output/src/libraries/network/MasterServerComm.h
r8351 r8832 93 93 * 94 94 * 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 ); 96 96 97 97 private: -
code/branches/output/src/libraries/network/NetworkPrereqs.h
r8829 r8832 129 129 class GamestateManager; 130 130 class Host; 131 class MasterServer; 132 class MasterServerComm; 131 133 class NetworkChatListener; 132 134 class NetworkFunctionBase; … … 136 138 class NetworkMemberFunction; 137 139 class NetworkMemberFunctionBase; 140 class PeerList; 138 141 class Server; 139 142 class ServerConnection; 140 143 class TrafficControl; 144 class WANDiscoverable; 145 class WANDiscovery; 141 146 142 147 // packet -
code/branches/output/src/libraries/network/Server.cc
r8829 r8832 59 59 #include "FunctionCallManager.h" 60 60 #include "GamestateManager.h" 61 #include "WANDiscovery.h"62 61 63 62 namespace orxonox … … 99 98 } 100 99 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 109 100 /** 110 101 * This function opens the server by creating the listener thread … … 121 112 /* make discoverable on WAN */ 122 113 WANDiscoverable::setActivity(true); 123 /* TODO this needs to be optional, we need a switch from the UI to124 * enable/disable this125 */126 // helper_ConnectToMasterserver();127 114 128 115 /* done */ … … 149 136 } 150 137 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 pollForReply159 * reimplementation160 */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 something170 * has to be done or changed.171 */172 //WANDiscovery::getInstance().msc.pollForReply( rhandler, 10 );173 }174 175 138 /** 176 139 * Run this function once every tick … … 185 148 // receive and process incoming discovery packets 186 149 LANDiscoverable::update(); 187 188 // receive and process requests from master server189 /* todo */190 //helper_HandleMasterServerRequests();191 150 192 151 if ( GamestateManager::hasPeers() ) -
code/branches/output/src/libraries/network/Server.h
r8829 r8832 42 42 #include "LANDiscoverable.h" 43 43 #include "WANDiscoverable.h" 44 // #include "MasterServerComm.h"45 // #include "MasterServerProtocol.h"46 44 47 45 … … 60 58 Server(int port, const std::string& bindAddress); 61 59 ~Server(); 62 63 /* helpers */64 void helper_ConnectToMasterserver();65 void helper_HandleMasterServerRequests();66 int replyhandler( char *addr, ENetEvent *ev );67 60 68 61 void open(); -
code/branches/output/src/libraries/network/WANDiscovery.cc
r8817 r8832 32 32 #include <cstring> 33 33 34 #include "util/ScopedSingletonManager.h"35 34 #include "core/CoreIncludes.h" 36 35 … … 38 37 namespace orxonox 39 38 { 40 ManageScopedSingleton(WANDiscovery, ScopeID::Graphics, true);41 42 43 39 WANDiscovery::WANDiscovery() 44 40 { … … 80 76 81 77 /* callback for the network reply poller */ 82 int rhandler( char *addr, ENetEvent *ev )78 int WANDiscovery::rhandler( char *addr, ENetEvent *ev ) 83 79 { 84 80 /* error recognition */ … … 103 99 104 100 /* add to list */ 105 WANDiscovery::getInstance().servers_.push_back( toadd );101 this->servers_.push_back( toadd ); 106 102 } 107 103 else if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_END, … … 132 128 { 133 129 /* poll for reply and act according to what was received */ 134 switch( this->msc.pollForReply( rhandler, 500 ) )130 switch( this->msc.pollForReply( this, 500 ) ) 135 131 { case 0: /* no event occured, decrease timeout */ 136 132 --i; break; -
code/branches/output/src/libraries/network/WANDiscovery.h
r8817 r8832 32 32 #include "packet/ServerInformation.h" 33 33 #include "core/ConfigFileManager.h" 34 #include "util/Singleton.h"35 34 #include "core/OrxonoxClass.h" 36 35 #include "core/ConfigValueIncludes.h" … … 49 48 class _NetworkExport WANDiscovery 50 49 // tolua_end 51 : public Singleton<WANDiscovery>, publicOrxonoxClass50 : public OrxonoxClass 52 51 { // tolua_export 53 friend class Singleton<WANDiscovery>;54 52 public: 55 53 /** constructor */ 56 WANDiscovery(); 54 WANDiscovery(); // tolua_export 57 55 58 56 /** destructor */ … … 83 81 std::string getServerListItemIP( unsigned int index ); // tolua_export 84 82 85 /** \return an instance of WANDiscovery86 *87 * Create and return an instance of WANDiscovery.88 */89 static WANDiscovery& getInstance() { return Singleton<WANDiscovery>::getInstance(); } // tolua_export90 91 83 /* todo: might make this private and use getter/setter methods 92 84 * at some later time. … … 100 92 /** Master server communications object */ 101 93 MasterServerComm msc; 94 95 int rhandler( char *addr, ENetEvent *ev ); 102 96 103 97 private: 104 /** Singleton pointer */105 static WANDiscovery* singletonPtr_s;106 107 98 /** master server address */ 108 99 std::string msaddress;
Note: See TracChangeset
for help on using the changeset viewer.