Changeset 7763 for code/branches/presentation
- Timestamp:
- Dec 15, 2010, 2:51:39 PM (14 years ago)
- Location:
- code/branches/presentation/src/libraries/network
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/libraries/network/MasterServer.cc
r7756 r7763 186 186 } 187 187 188 else if( !strncmp( (char *)event->packet->data 189 + MSPROTO_GAME_SERVER_LEN+1, 190 MSPROTO_SERVERDC, MSPROTO_SERVERDC_LEN ) ) 191 { 192 /* create string from peer data */ 193 std::string name = std::string( addrconv ); 194 195 /* remove the server from the list it belongs to */ 196 this->mainlist.delServerByName( name ); 197 198 /* tell the user */ 199 COUT(2) << "Removed server " << name << " from list.\n"; 200 } 201 188 202 /* TODO add hook for disconnect here */ 189 203 } -
code/branches/presentation/src/libraries/network/MasterServerComm.cc
r7761 r7763 41 41 { 42 42 /* initialize Enet */ 43 if (enet_initialize () != 0)43 if( enet_initialize () != 0 ) 44 44 { COUT(1) << "An error occurred while initializing ENet.\n"; 45 45 return 1; … … 59 59 /* see if it worked */ 60 60 if (this->client == NULL) 61 { COUT(1) << "An error occurred while trying to create an ENet client host.\n"; 61 { COUT(1) << "An error occurred while trying to create an " 62 << "ENet client host.\n"; 62 63 return 1; 63 64 } … … 70 71 /* destroy the enet facilities */ 71 72 enet_host_destroy(this->client); 72 73 /* install atexit handler for enet */74 enet_deinitialize();75 73 } 76 74 … … 84 82 this->peer = enet_host_connect(this->client, &this->address, 2, 0); 85 83 86 if (this->peer == NULL ) 87 { COUT(2) << "ERROR: No available peers for initiating an ENet connection.\n"; 84 if( this->peer == NULL ) 85 { COUT(2) << "ERROR: No available peers for initiating an ENet" 86 << " connection.\n"; 88 87 return -1; 89 88 } … … 96 95 { 97 96 enet_peer_reset (this->peer); 98 fprintf( stdout, "Connection to %s failed.", address );99 97 COUT(2) << "ERROR: connection to " << address << " failed.\n"; 100 98 return -1; … … 240 238 /* One could just use enet_host_service() instead. */ 241 239 enet_host_flush( this->client ); 242 if( packet ) free( packet );240 enet_packet_destroy( packet ); 243 241 244 242 /* all done. */ -
code/branches/presentation/src/libraries/network/MasterServerComm.h
r7761 r7763 66 66 * Disconnect from master server. 67 67 */ 68 int disconnect( );68 int disconnect( void ); 69 69 70 70 /** \param data The data to be sent. -
code/branches/presentation/src/libraries/network/MasterServerProtocol.h
r7756 r7763 69 69 #define MSPROTO_PING_GAMESERVER_LEN 4 70 70 71 /* server disconnect */ 72 #define MSPROTO_SERVERDC "DC" 73 #define MSPROTO_SERVERDC_LEN 2 74 71 75 /* ping reply */ 72 76 #define MSPROTO_ACK "ACK" -
code/branches/presentation/src/libraries/network/Server.cc
r7762 r7763 104 104 void Server::helper_ConnectToMasterserver() 105 105 { 106 / * initialize it and see if it worked */107 if( msc.initialize() )108 { COUT(1) << "Error: could not initialize master server communications!\n";109 return;110 }111 112 / * connect and see if it worked */113 if( msc.connect( WANDiscovery::getInstance().getMSAddress().c_str(),114 ORX_MSERVER_PORT ) )115 { COUT(1) << "Error: could not connect to master server!\n";116 return;117 }106 //[> initialize it and see if it worked <] 107 //if( msc.initialize() ) 108 //{ COUT(1) << "Error: could not initialize master server communications!\n"; 109 //return; 110 //} 111 112 //[> connect and see if it worked <] 113 //if( msc.connect( WANDiscovery::getInstance().getMSAddress().c_str(), 114 //ORX_MSERVER_PORT ) ) 115 //{ COUT(1) << "Error: could not connect to master server!\n"; 116 //return; 117 //} 118 118 119 119 /* now send the master server some note we're here */ 120 msc.sendRequest( MSPROTO_GAME_SERVER " " MSPROTO_REGISTER_SERVER ); 120 //msc.sendRequest( MSPROTO_GAME_SERVER " " MSPROTO_REGISTER_SERVER ); 121 WANDiscovery::getInstance().msc.sendRequest( MSPROTO_GAME_SERVER " " 122 MSPROTO_REGISTER_SERVER ); 121 123 } 122 124 … … 152 154 this->disconnectClients(); 153 155 this->closeListener(); 156 157 /* tell master server we're closing */ 154 158 COUT(2) << "disconnecting." << endl; 155 this->msc.disconnect(); 159 WANDiscovery::getInstance().msc.sendRequest( MSPROTO_GAME_SERVER " " 160 MSPROTO_SERVERDC ); 156 161 COUT(2) << "disconnecting done" << endl; 162 157 163 LANDiscoverable::setActivity(false); 158 164 return; … … 196 202 * has to be done or changed. 197 203 */ 198 this->msc.pollForReply( rephandler, 10 );204 //WANDiscovery::getInstance().msc.pollForReply( rhandler, 10 ); 199 205 } 200 206 -
code/branches/presentation/src/libraries/network/Server.h
r7739 r7763 90 90 91 91 float timeSinceLastUpdate_; 92 MasterServerComm msc;92 //MasterServerComm msc; 93 93 }; 94 94 -
code/branches/presentation/src/libraries/network/WANDiscovery.cc
r7756 r7763 133 133 { 134 134 /* poll for reply and act according to what was received */ 135 switch( this->msc.pollForReply( rhandler, 1000 ) )135 switch( this->msc.pollForReply( rhandler, 500 ) ) 136 136 { case 0: /* no event occured, decrease timeout */ 137 137 --i; break; -
code/branches/presentation/src/libraries/network/WANDiscovery.h
r7750 r7763 95 95 /** Function used for the configuration file parameter update */ 96 96 void setConfigValues(); 97 98 /** Master server communications object */ 99 MasterServerComm msc; 97 100 98 101 private: 99 102 /** Singleton pointer */ 100 103 static WANDiscovery* singletonPtr_s; 101 102 /** Master server communications object */103 MasterServerComm msc;104 104 105 105 /** master server address */
Note: See TracChangeset
for help on using the changeset viewer.