- Timestamp:
- May 31, 2008, 1:09:12 PM (16 years ago)
- Location:
- code/branches/network/src/network
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/network/ClientConnection.cc
r1491 r1492 133 133 } 134 134 135 // bool ClientConnection::sendPackets(ENetEvent *event) {136 // if(server==NULL)137 // return false;138 // if(enet_host_service(client, event, NETWORK_SEND_WAIT)>=0){139 // return true;}140 // else141 // return false;142 // }143 144 135 bool ClientConnection::sendPackets() { 145 ENetEvent event;146 136 if(server==NULL) 147 137 return false; 148 138 boost::recursive_mutex::scoped_lock lock(enet_mutex_); 149 139 enet_host_flush(client); 140 lock.unlock(); 150 141 return true; 151 142 } … … 159 150 enet_initialize(); 160 151 client = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0); 152 lock.unlock(); 161 153 } 162 154 if(client==NULL) { … … 183 175 // add some error handling here ======================== 184 176 } 177 lock.unlock(); 185 178 } 186 179 switch(event->type){ … … 201 194 continue; 202 195 } 203 //receiverThread_->yield();196 receiverThread_->yield(); 204 197 } 205 198 // now disconnect -
code/branches/network/src/network/ClientConnection.h
r1491 r1492 54 54 #define NETWORK_PORT 55556 55 55 #define NETWORK_CLIENT_MAX_CONNECTIONS 5 56 #define NETWORK_CLIENT_TIMEOUT 1000 57 #define NETWORK_SEND_WAIT 500 56 #define NETWORK_CLIENT_TIMEOUT 10 58 57 #define NETWORK_CLIENT_CHANNELS 2 59 58 -
code/branches/network/src/network/ConnectionManager.cc
r1491 r1492 169 169 } 170 170 171 /*bool ConnectionManager::sendPackets(ENetEvent *event) {172 if(server==NULL)173 return false;174 if(enet_host_service(server, event, NETWORK_SEND_WAIT)>=0)175 return true;176 else177 return false;178 }*/179 180 171 bool ConnectionManager::sendPackets() { 181 172 if(server==NULL) … … 183 174 boost::recursive_mutex::scoped_lock lock(enet_mutex_); 184 175 enet_host_flush(server); 176 lock.unlock(); 185 177 return true; 186 178 } … … 194 186 enet_initialize(); 195 187 server = enet_host_create(&bindAddress, NETWORK_MAX_CONNECTIONS, 0, 0); 188 lock.unlock(); 196 189 } 197 190 if(server==NULL){ … … 211 204 // add some error handling here ======================== 212 205 } 206 lock.unlock(); 213 207 } 214 208 switch(event->type){ … … 235 229 case ENET_EVENT_TYPE_NONE: 236 230 delete event; 237 //receiverThread_->yield();231 receiverThread_->yield(); 238 232 break; 239 233 } … … 246 240 boost::recursive_mutex::scoped_lock lock(enet_mutex_); 247 241 enet_host_destroy(server); 242 lock.unlock(); 248 243 } 249 244 } … … 259 254 boost::recursive_mutex::scoped_lock lock(enet_mutex_); 260 255 enet_peer_disconnect(temp->getPeer(), 0); 256 lock.unlock(); 261 257 } 262 258 temp = temp->next(); … … 439 435 boost::recursive_mutex::scoped_lock lock(enet_mutex_); 440 436 enet_peer_disconnect(client->getPeer(), 0); 437 lock.unlock(); 441 438 } 442 439 removeShip(client); -
code/branches/network/src/network/ConnectionManager.h
r1491 r1492 62 62 #define NETWORK_PORT 55556 63 63 #define NETWORK_MAX_CONNECTIONS 50 64 #define NETWORK_WAIT_TIMEOUT 5000 65 #define NETWORK_SEND_WAIT 5 64 #define NETWORK_WAIT_TIMEOUT 10 66 65 67 66 struct ClientList{
Note: See TracChangeset
for help on using the changeset viewer.