Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 3, 2007, 12:28:19 AM (16 years ago)
Author:
scheusso
Message:

PacketDecoder:

Extended Class to make inheriting easier…

-added virtual function, that can be implemented by lower classes

Client:

Added some function, changed some things (input, gamestate, connectionhandling)

Server:

same as client

File:
1 edited

Legend:

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

    r337 r369  
    2121  Client::Client(): client_connection(NETWORK_PORT,"127.0.0.1"){
    2222    // set server address to localhost
    23     //server_address="127.0.0.1";
    24     //port = NETWORK_PORT;
    2523    isConnected=false;
     24    pck_gen = PacketGenerator();
     25    gamestate = GameStateManager();
    2626  }
    2727
     
    3232   */
    3333  Client::Client(std::string address, int port) : client_connection(port, address){
    34     //server_address=address.c_str();
    35     //this->port = port;
    3634    isConnected=false;
     35    pck_gen = PacketGenerator();
     36    gamestate = GameStateManager();
    3737  }
    3838
     
    4343   */
    4444  Client::Client(const char *address, int port) : client_connection(port, address){
    45     //server_address = address;
    46     //this->port = port;
    4745    isConnected=false;
     46    pck_gen = PacketGenerator();
     47    gamestate = GameStateManager();
    4848  }
    4949
     
    7878        return false;
    7979    // send packets
    80     client_connection.sendPackets(&event);
    81     if(event.type==ENET_EVENT_TYPE_NONE)
    82       return true;
    83     else
    84       return false;
     80    return client_connection.sendPackets();
    8581  }
    8682
     
    9692        return false;
    9793    // send packets
    98     client_connection.sendPackets(&event);
    99     if(event.type==ENET_EVENT_TYPE_NONE)
    100       return true;
    101     else
    102       return false;
     94    return client_connection.sendPackets();
    10395  }
    10496
     
    131123  }
    132124
     125  /**
     126   * Sends out all the packets queued by addXXX
     127   */
     128  bool Client::sendPackets(){
     129    ENetEvent event;
     130    // send packets
     131    client_connection.sendPackets(&event);
     132    if(event.type==ENET_EVENT_TYPE_NONE)
     133      return true;
     134    else
     135      return false;
     136  }
     137 
    133138  /**
    134139   * Performs a GameState update
    135140   */
    136141  void Client::update(){
    137     // to be implemented ==================
    138 
    139 
     142    ENetPacket *packet;
     143    // stop if the packet queue is empty
     144    while(!client_connection.queueEmpty()){
     145      packet = client_connection.getPacket();
     146      elaborate(packet, 0); // ================= i guess we got to change this .... (client_ID is always same = server)
     147    }
     148    return;
    140149  }
    141 
     150 
     151  void Client::processGamestate( GameState *data){
     152    gamestate.loadSnapshot( *data );
     153    return;
     154  }
     155 
    142156}
Note: See TracChangeset for help on using the changeset viewer.