Changeset 7761
- Timestamp:
- Dec 15, 2010, 1:39:56 PM (14 years ago)
- Location:
- code/branches/presentation/src/libraries/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation/src/libraries/network/MasterServerComm.cc
r7756 r7761 49 49 this->event = (ENetEvent *)calloc( sizeof(ENetEvent), 1 ); 50 50 51 /* install atexit handler for enet */52 atexit( enet_deinitialize );53 51 54 52 /* initiate the client */ … … 72 70 /* destroy the enet facilities */ 73 71 enet_host_destroy(this->client); 72 73 /* install atexit handler for enet */ 74 enet_deinitialize(); 74 75 } 75 76 … … 101 102 102 103 /* all fine */ 104 return 0; 105 } 106 107 int MasterServerComm::disconnect( void ) 108 { 109 enet_peer_disconnect( this->peer, 0 ); 110 111 /* Allow up to 1 second for the disconnect to succeed 112 * and drop any packets received packets. 113 */ 114 while (enet_host_service (this->client, this->event, 1000) > 0) 115 { 116 switch (this->event->type) 117 { 118 case ENET_EVENT_TYPE_RECEIVE: 119 enet_packet_destroy (event->packet); 120 break; 121 122 case ENET_EVENT_TYPE_DISCONNECT: 123 COUT(4) << "Disconnect from master server successful.\n"; 124 return 0; 125 default: break; 126 } 127 } 128 129 /* We've arrived here, so the disconnect attempt didn't 130 * succeed yet, hence: force the connection down. 131 */ 132 enet_peer_reset( this->peer ); 133 134 /* done */ 103 135 return 0; 104 136 } -
code/branches/presentation/src/libraries/network/MasterServerComm.h
r7756 r7761 62 62 int connect( const char *address, unsigned int port ); 63 63 64 /** \return 0 for success, other for error 65 * 66 * Disconnect from master server. 67 */ 68 int disconnect(); 69 64 70 /** \param data The data to be sent. 65 71 * \return 0 for success, other for error. -
code/branches/presentation/src/libraries/network/Server.cc
r7756 r7761 152 152 this->disconnectClients(); 153 153 this->closeListener(); 154 this->msc.disconnect(); 154 155 LANDiscoverable::setActivity(false); 155 156 return;
Note: See TracChangeset
for help on using the changeset viewer.