Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1377 for code/branches


Ignore:
Timestamp:
May 22, 2008, 4:23:29 PM (16 years ago)
Author:
dumenim
Message:

some changes on clientside (replaces some enet_host_service with enet_host_flush and so on)

Location:
code/branches/network/src/network
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/Client.cc

    r1360 r1377  
    122122      COUT(3) << "sending connectrequest" << std::endl;
    123123      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;
    125125    }else
    126       COUT(1) << "could not create connection" << std::endl;
     126      COUT(1) << "could not create connection laber" << std::endl;
    127127    return isConnected;
    128128  }
     
    216216    if(!isConnected)
    217217      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;
    225221  }
    226222
  • code/branches/network/src/network/ClientConnection.cc

    r1293 r1377  
    9898    //network_threads.create_thread(boost::bind(boost::mem_fn(&ClientConnection::receiverThread), this));
    9999    // wait 10 seconds for the connection to be established
    100     return waitEstablished(10000);
     100    return waitEstablished(3000);
    101101  }
    102102
     
    123123  }
    124124
    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;
    126136    if(server==NULL)
    127137      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;
    142140  }
    143141
     
    148146    ENetEvent event;
    149147    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;
    151150      // add some error handling here ==========================
    152151      quit=true;
     152    }
    153153    //connect to the server
    154154    if(!establishConnection()){
     155      COUT(2) << "clientConn: receiver thread: could not establishConnection" << std::endl;
    155156      quit=true;
    156157      return;
     
    167168        // log handling ================
    168169      case ENET_EVENT_TYPE_CONNECT:
     170        break;
    169171      case ENET_EVENT_TYPE_RECEIVE:
    170172        COUT(5) << "Cl.Con: receiver-Thread while loop: got new packet" << std::endl;
     
    213215    // connect to peer (server is type ENetPeer*)
    214216    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;
    216219      // error handling
    217220      return false;
     221    }
    218222    // 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){
    220224      established=true;
    221225      return true;
    222226    }
    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    }
    225231  }
    226232
  • code/branches/network/src/network/ClientConnection.h

    r1293 r1377  
    5454#define NETWORK_PORT 55556
    5555#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
    5858#define NETWORK_CLIENT_CHANNELS 2
    5959
     
    7575    bool sendPackets();
    7676    // send out all queued packets and save result in event
    77     bool sendPackets(ENetEvent *event);
     77    //bool sendPackets(ENetEvent *event);
    7878    bool waitEstablished(int milisec);
    7979    bool isConnected(){return established;}
Note: See TracChangeset for help on using the changeset viewer.