Changeset 1377 for code/branches/network/src
- Timestamp:
- May 22, 2008, 4:23:29 PM (17 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/Client.cc
r1360 r1377 122 122 COUT(3) << "sending connectrequest" << std::endl; 123 123 if(!client_connection.addPacket(pck_gen.generateConnectRequest()) || !client_connection.sendPackets()) 124 COUT(1) << "could not create connection" << std::endl;124 COUT(1) << "could not send connection request !!!!!!!!!" << std::endl; 125 125 }else 126 COUT(1) << "could not create connection " << std::endl;126 COUT(1) << "could not create connection laber" << std::endl; 127 127 return isConnected; 128 128 } … … 216 216 if(!isConnected) 217 217 return false; 218 ENetEvent event; 219 // send packets 220 client_connection.sendPackets(&event); 221 if(event.type==ENET_EVENT_TYPE_NONE) 222 return true; 223 else 224 return false; 218 // send packets 219 client_connection.sendPackets(); 220 return true; 225 221 } 226 222 -
code/branches/network/src/network/ClientConnection.cc
r1293 r1377 98 98 //network_threads.create_thread(boost::bind(boost::mem_fn(&ClientConnection::receiverThread), this)); 99 99 // wait 10 seconds for the connection to be established 100 return waitEstablished( 10000);100 return waitEstablished(3000); 101 101 } 102 102 … … 123 123 } 124 124 125 bool ClientConnection::sendPackets(ENetEvent *event) { 125 // bool ClientConnection::sendPackets(ENetEvent *event) { 126 // if(server==NULL) 127 // return false; 128 // if(enet_host_service(client, event, NETWORK_SEND_WAIT)>=0){ 129 // return true;} 130 // else 131 // return false; 132 // } 133 134 bool ClientConnection::sendPackets() { 135 ENetEvent event; 126 136 if(server==NULL) 127 137 return false; 128 if(enet_host_service(client, event, NETWORK_SEND_WAIT)>=0){ 129 return true;} 130 else 131 return false; 132 } 133 134 bool ClientConnection::sendPackets() { 135 ENetEvent event; 136 if(server==NULL) 137 return false; 138 if(enet_host_service(client, &event, NETWORK_SEND_WAIT)>=0){ 139 return true;} 140 else 141 return false; 138 enet_host_flush(client); 139 return true; 142 140 } 143 141 … … 148 146 ENetEvent event; 149 147 client = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0); 150 if(client==NULL) 148 if(client==NULL) { 149 COUT(2) << "ClientConnection: could not create client host" << std::endl; 151 150 // add some error handling here ========================== 152 151 quit=true; 152 } 153 153 //connect to the server 154 154 if(!establishConnection()){ 155 COUT(2) << "clientConn: receiver thread: could not establishConnection" << std::endl; 155 156 quit=true; 156 157 return; … … 167 168 // log handling ================ 168 169 case ENET_EVENT_TYPE_CONNECT: 170 break; 169 171 case ENET_EVENT_TYPE_RECEIVE: 170 172 COUT(5) << "Cl.Con: receiver-Thread while loop: got new packet" << std::endl; … … 213 215 // connect to peer (server is type ENetPeer*) 214 216 server = enet_host_connect(client, &serverAddress, NETWORK_CLIENT_CHANNELS); 215 if(server==NULL) 217 if(server==NULL) { 218 COUT(2) << "ClientConnection: server == NULL" << std::endl; 216 219 // error handling 217 220 return false; 221 } 218 222 // handshake 219 if(enet_host_service(client, &event, NETWORK_CLIENT_TIMEOUT)> 0 && event.type == ENET_EVENT_TYPE_CONNECT){223 if(enet_host_service(client, &event, NETWORK_CLIENT_TIMEOUT)>=0 && event.type == ENET_EVENT_TYPE_CONNECT){ 220 224 established=true; 221 225 return true; 222 226 } 223 else 224 return false; 227 else { 228 COUT(2) << "ClientConnection: enet_host_service < 0 or event.type != ENET_EVENT_TYPE_CONNECT # EVENT:" << event.type << std::endl; 229 return false; 230 } 225 231 } 226 232 -
code/branches/network/src/network/ClientConnection.h
r1293 r1377 54 54 #define NETWORK_PORT 55556 55 55 #define NETWORK_CLIENT_MAX_CONNECTIONS 5 56 #define NETWORK_CLIENT_TIMEOUT 100 57 #define NETWORK_SEND_WAIT 5 56 #define NETWORK_CLIENT_TIMEOUT 10000 57 #define NETWORK_SEND_WAIT 500 58 58 #define NETWORK_CLIENT_CHANNELS 2 59 59 … … 75 75 bool sendPackets(); 76 76 // send out all queued packets and save result in event 77 bool sendPackets(ENetEvent *event);77 //bool sendPackets(ENetEvent *event); 78 78 bool waitEstablished(int milisec); 79 79 bool isConnected(){return established;}
Note: See TracChangeset
for help on using the changeset viewer.