Changeset 2965 for code/branches/netp2/src/network/ClientConnection.cc
- Timestamp:
- May 11, 2009, 1:42:10 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp2/src/network/ClientConnection.cc
r2836 r2965 58 58 59 59 ClientConnection::ClientConnection(int port, const std::string& address) { 60 quit =false;60 quit_=false; 61 61 server=NULL; 62 62 serverAddress = new ENetAddress(); … … 67 67 68 68 ClientConnection::ClientConnection(int port, const char *address) { 69 quit =false;69 quit_=false; 70 70 server=NULL; 71 71 serverAddress = new ENetAddress(); … … 107 107 108 108 bool ClientConnection::closeConnection() { 109 quit =true;109 quit_=true; 110 110 //network_threads.join_all(); 111 111 receiverThread_->join(); … … 151 151 COUT(2) << "ClientConnection: could not create client host" << std::endl; 152 152 // add some error handling here ========================== 153 quit =true;153 quit_=true; 154 154 } 155 155 //connect to the server 156 156 if(!establishConnection()){ 157 157 COUT(2) << "clientConn: receiver thread: could not establishConnection" << std::endl; 158 quit =true;158 quit_=true; 159 159 return; 160 160 } 161 161 event = new ENetEvent; 162 162 //main loop 163 while(!quit ){163 while(!quit_){ 164 164 //std::cout << "connection loop" << std::endl; 165 165 { … … 167 167 if(enet_host_service(client, event, NETWORK_CLIENT_WAIT_TIME)<0){ 168 168 // we should never reach this point 169 assert(0); 170 quit=true; 171 continue; 169 // assert(0); 170 printf("ClientConnection: ENet returned with an error!\n"); 171 quit_=true; 172 break; 172 173 // add some error handling here ======================== 173 174 } … … 185 186 break; 186 187 case ENET_EVENT_TYPE_DISCONNECT: 187 quit=true; 188 quit_=true; 189 printf("Received disconnect Packet from Server!\n"); 188 190 // server closed the connection 189 191 return; … … 235 237 } 236 238 // handshake 237 while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME)>=0 && !quit ){239 while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME)>=0 && !quit_){ 238 240 if( event.type == ENET_EVENT_TYPE_CONNECT ){ 239 241 established=true;
Note: See TracChangeset
for help on using the changeset viewer.