Changeset 369 for code/branches/FICN/src/network/Client.cc
- Timestamp:
- Dec 3, 2007, 12:28:19 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/Client.cc
r337 r369 21 21 Client::Client(): client_connection(NETWORK_PORT,"127.0.0.1"){ 22 22 // set server address to localhost 23 //server_address="127.0.0.1";24 //port = NETWORK_PORT;25 23 isConnected=false; 24 pck_gen = PacketGenerator(); 25 gamestate = GameStateManager(); 26 26 } 27 27 … … 32 32 */ 33 33 Client::Client(std::string address, int port) : client_connection(port, address){ 34 //server_address=address.c_str();35 //this->port = port;36 34 isConnected=false; 35 pck_gen = PacketGenerator(); 36 gamestate = GameStateManager(); 37 37 } 38 38 … … 43 43 */ 44 44 Client::Client(const char *address, int port) : client_connection(port, address){ 45 //server_address = address;46 //this->port = port;47 45 isConnected=false; 46 pck_gen = PacketGenerator(); 47 gamestate = GameStateManager(); 48 48 } 49 49 … … 78 78 return false; 79 79 // 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(); 85 81 } 86 82 … … 96 92 return false; 97 93 // 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(); 103 95 } 104 96 … … 131 123 } 132 124 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 133 138 /** 134 139 * Performs a GameState update 135 140 */ 136 141 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; 140 149 } 141 150 151 void Client::processGamestate( GameState *data){ 152 gamestate.loadSnapshot( *data ); 153 return; 154 } 155 142 156 }
Note: See TracChangeset
for help on using the changeset viewer.