Changeset 2990 for code/branches/netp3/src/network/ClientConnection.cc
- Timestamp:
- May 19, 2009, 9:35:10 PM (15 years ago)
- Location:
- code/branches/netp3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp3
- Property svn:mergeinfo changed
/code/branches/netp2 (added) merged: 2835-2836,2861,2937-2938,2940-2941,2943-2945,2947-2949,2951,2953,2964-2965,2974-2976
- Property svn:mergeinfo changed
-
code/branches/netp3/src/network/ClientConnection.cc
r2773 r2990 42 42 #include <enet/enet.h> 43 43 #include <iostream> 44 #include <cassert> 44 45 // boost.thread library for multithreading support 45 46 #include <boost/thread/thread.hpp> … … 57 58 58 59 ClientConnection::ClientConnection(int port, const std::string& address) { 59 quit =false;60 quit_=false; 60 61 server=NULL; 61 62 serverAddress = new ENetAddress(); … … 66 67 67 68 ClientConnection::ClientConnection(int port, const char *address) { 68 quit =false;69 quit_=false; 69 70 server=NULL; 70 71 serverAddress = new ENetAddress(); … … 106 107 107 108 bool ClientConnection::closeConnection() { 108 quit =true;109 quit_=true; 109 110 //network_threads.join_all(); 110 111 receiverThread_->join(); … … 150 151 COUT(2) << "ClientConnection: could not create client host" << std::endl; 151 152 // add some error handling here ========================== 152 quit =true;153 quit_=true; 153 154 } 154 155 //connect to the server 155 156 if(!establishConnection()){ 156 157 COUT(2) << "clientConn: receiver thread: could not establishConnection" << std::endl; 157 quit =true;158 quit_=true; 158 159 return; 159 160 } 160 161 event = new ENetEvent; 161 162 //main loop 162 while(!quit ){163 while(!quit_){ 163 164 //std::cout << "connection loop" << std::endl; 164 165 { … … 166 167 if(enet_host_service(client, event, NETWORK_CLIENT_WAIT_TIME)<0){ 167 168 // we should never reach this point 168 quit=true; 169 continue; 169 // assert(0); 170 printf("ClientConnection: ENet returned with an error!\n"); 171 quit_=true; 172 break; 170 173 // add some error handling here ======================== 171 174 } … … 183 186 break; 184 187 case ENET_EVENT_TYPE_DISCONNECT: 185 quit=true; 188 quit_=true; 189 printf("Received disconnect Packet from Server!\n"); 186 190 // server closed the connection 187 191 return; … … 206 210 boost::recursive_mutex::scoped_lock lock(enet_mutex_g); 207 211 enet_peer_disconnect(server, 0); 208 while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) > 0){212 while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) >= 0){ 209 213 switch (event.type) 210 214 { … … 233 237 } 234 238 // handshake 235 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_){ 236 240 if( event.type == ENET_EVENT_TYPE_CONNECT ){ 237 241 established=true;
Note: See TracChangeset
for help on using the changeset viewer.