Changeset 7739 for code/branches/presentation/src/libraries/network
- Timestamp:
- Dec 8, 2010, 4:25:52 PM (14 years ago)
- 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 32 32 LANDiscoverable.cc 33 33 LANDiscovery.cc 34 WANDiscovery.cc 35 MasterServerComm.cc 34 36 NetworkFunction.cc 35 37 Host.cc 36 38 Server.cc 39 MasterServer.cc 40 PeerList.cc 41 ServerList.cc 37 42 ServerConnection.cc 38 43 TrafficControl.cc … … 54 59 LANDiscoverable.h 55 60 LANDiscovery.h 61 WANDiscovery.h 62 MasterServerComm.h 56 63 NetworkFunction.h 57 64 NetworkPrecompiledHeaders.h 58 65 NetworkPrereqs.h 59 66 Server.h 67 MasterServer.h 68 PeerList.h 69 ServerList.h 60 70 ServerConnection.h 61 71 TrafficControl.h … … 69 79 Client.h 70 80 LANDiscovery.h 81 WANDiscovery.h 71 82 PCH_FILE 72 83 NetworkPrecompiledHeaders.h -
code/branches/presentation/src/libraries/network/Server.cc
r7284 r7739 99 99 } 100 100 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 101 121 /** 102 122 * This function opens the server by creating the listener thread … … 107 127 COUT(4) << "opening server" << endl; 108 128 this->openListener(); 129 130 /* make discoverable on LAN */ 109 131 LANDiscoverable::setActivity(true); 132 133 /* make discoverable on WAN */ 134 helper_ConnectToMasterserver(); 135 136 /* done */ 110 137 return; 111 138 } … … 140 167 141 168 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 142 183 /** 143 184 * Run this function once every tick … … 149 190 // receive incoming packets 150 191 Connection::processQueue(); 192 151 193 // receive and process incoming discovery packets 152 194 LANDiscoverable::update(); 195 196 // receive and process requests from master server 197 helper_HandleMasterServerRequests(); 153 198 154 199 if ( ClientInformation::hasClients() ) -
code/branches/presentation/src/libraries/network/Server.h
r7163 r7739 38 38 #include "ServerConnection.h" 39 39 #include "LANDiscoverable.h" 40 #include "MasterServerComm.h" 41 #include "MasterServerProtocol.h" 42 40 43 41 44 namespace orxonox … … 52 55 Server(int port, const std::string& bindAddress); 53 56 ~Server(); 57 58 /* helpers */ 59 void helper_ConnectToMasterserver(); 60 void helper_HandleMasterServerRequests(); 61 int replyhandler( char *addr, ENetEvent *ev ); 54 62 55 63 void open(); … … 82 90 83 91 float timeSinceLastUpdate_; 92 MasterServerComm msc; 84 93 }; 85 94 -
code/branches/presentation/src/libraries/network/WANDiscovery.cc
r7737 r7739 41 41 ManageScopedSingleton(WANDiscovery, ScopeID::Root, true); 42 42 43 void WANDiscovery::setConfigValues()44 {45 SetConfigValue(this->msaddr, "msaddr");46 }47 43 48 44 WANDiscovery::WANDiscovery() … … 54 50 RegisterObject(WANDiscovery); 55 51 56 /* set default string for this->msaddr */57 this->msaddr = "localhost";58 59 52 /* ... and register a config value function for it */ 60 53 this->setConfigValues(); … … 65 58 66 59 /* connect and see if it worked */ 67 if( msc.connect( this->msaddr .c_str(), 1234 ) )60 if( msc.connect( this->msaddress.c_str(), 1234 ) ) 68 61 COUT(2) << "Error: could not connect to master server at " 69 << this->msaddr << std::endl;62 << this->msaddress << std::endl; 70 63 71 64 /* debugging output */ 72 65 COUT(4) << "Initialization of WANDiscovery complete.\n"; 73 66 } 67 68 void WANDiscovery::setConfigValues() 69 { 70 SetConfigValue( msaddress, "localhost"); 71 } 74 72 75 73 WANDiscovery::~WANDiscovery() -
code/branches/presentation/src/libraries/network/WANDiscovery.h
r7737 r7739 100 100 101 101 /** master server address */ 102 std::string msaddr ;102 std::string msaddress; 103 103 104 104 }; // tolua_export -
code/branches/presentation/src/libraries/network/packet/ServerInformation.h
r7459 r7739 50 50 std::string getServerName() { return this->serverName_; } 51 51 void setServerName(std::string name) { this->serverName_ = name; } 52 void setServerIP( std::string IP ) { this->serverIP_ = IP; } 52 53 uint32_t getServerRTT() { return this->serverRTT_; } 53 54
Note: See TracChangeset
for help on using the changeset viewer.