Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 11, 2009, 1:42:10 PM (15 years ago)
Author:
scheusso
Message:

some fixes (bidirectional variables, …), some changes (client tickrate, connection handling)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp2/src/network/ClientConnection.cc

    r2836 r2965  
    5858
    5959  ClientConnection::ClientConnection(int port, const std::string& address) {
    60     quit=false;
     60    quit_=false;
    6161    server=NULL;
    6262    serverAddress = new ENetAddress();
     
    6767
    6868  ClientConnection::ClientConnection(int port, const char *address) {
    69     quit=false;
     69    quit_=false;
    7070    server=NULL;
    7171    serverAddress = new ENetAddress();
     
    107107
    108108  bool ClientConnection::closeConnection() {
    109     quit=true;
     109    quit_=true;
    110110    //network_threads.join_all();
    111111    receiverThread_->join();
     
    151151      COUT(2) << "ClientConnection: could not create client host" << std::endl;
    152152      // add some error handling here ==========================
    153       quit=true;
     153      quit_=true;
    154154    }
    155155    //connect to the server
    156156    if(!establishConnection()){
    157157      COUT(2) << "clientConn: receiver thread: could not establishConnection" << std::endl;
    158       quit=true;
     158      quit_=true;
    159159      return;
    160160    }
    161161    event = new ENetEvent;
    162162    //main loop
    163     while(!quit){
     163    while(!quit_){
    164164      //std::cout << "connection loop" << std::endl;
    165165      {
     
    167167        if(enet_host_service(client, event, NETWORK_CLIENT_WAIT_TIME)<0){
    168168          // 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;
    172173          // add some error handling here ========================
    173174        }
     
    185186        break;
    186187      case ENET_EVENT_TYPE_DISCONNECT:
    187         quit=true;
     188        quit_=true;
     189        printf("Received disconnect Packet from Server!\n");
    188190        // server closed the connection
    189191        return;
     
    235237    }
    236238    // 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_){
    238240      if( event.type == ENET_EVENT_TYPE_CONNECT ){
    239241        established=true;
Note: See TracChangeset for help on using the changeset viewer.