Index: code/trunk/src/network/Client.cc
===================================================================
--- code/trunk/src/network/Client.cc	(revision 3198)
+++ code/trunk/src/network/Client.cc	(revision 3214)
@@ -39,20 +39,17 @@
 //
 
+#include "Client.h"
+
 #include <cassert>
-#include <enet/enet.h>
 
-#include "Client.h"
-#include "Host.h"
+#include "util/Debug.h"
+#include "core/Clock.h"
 #include "synchronisable/Synchronisable.h"
-#include "core/Clock.h"
-#include "core/CoreIncludes.h"
-#include "packet/Packet.h"
+#include "packet/Chat.h"
+#include "packet/Gamestate.h"
 #include "FunctionCallManager.h"
-
-// #include "packet/Acknowledgement.h"
 
 namespace orxonox
 {
-//   SetConsoleCommandShortcut(Client, chat);
 
 
@@ -61,9 +58,8 @@
   * initializes the address and the port to default localhost:NETWORK_PORT
   */
-  Client::Client(): client_connection(NETWORK_PORT,"127.0.0.1"){
-    // set server address to localhost
-    isConnected=false;
-    isSynched_=false;
-    gameStateFailure_=false;
+  Client::Client():
+      isSynched_(false),
+      gameStateFailure_(false)
+  {
   }
 
@@ -73,23 +69,14 @@
   * @param port port of the application on the server
   */
-  Client::Client(const std::string& address, int port) : client_connection(port, address){
-    isConnected=false;
-    isSynched_=false;
-    gameStateFailure_=false;
-  }
-
-  /**
-  * Constructor for the Client class
-  * @param address the server address
-  * @param port port of the application on the server
-  */
-  Client::Client(const char *address, int port) : client_connection(port, address){
-    isConnected=false;
-    isSynched_=false;
-    gameStateFailure_=false;
+  Client::Client(const std::string& address, int port):
+      isSynched_(false),
+      gameStateFailure_(false)
+  {
+      setPort( port );
+      setServerAddress( address );
   }
 
   Client::~Client(){
-    if(isConnected)
+    if ( ClientConnection::isConnected() )
       closeConnection();
   }
@@ -101,8 +88,5 @@
   bool Client::establishConnection(){
     Synchronisable::setClient(true);
-    isConnected=client_connection.createConnection();
-    if(!isConnected)
-      COUT(1) << "could not create connection laber" << std::endl;
-    return isConnected;
+    return ClientConnection::establishConnection();
   }
 
@@ -112,10 +96,11 @@
   */
   bool Client::closeConnection(){
-    isConnected=false;
-    return client_connection.closeConnection();
+    return ClientConnection::closeConnection();
   }
 
   bool Client::queuePacket(ENetPacket *packet, int clientID){
-    return client_connection.addPacket(packet);
+    bool b = ClientConnection::addPacket(packet);
+    assert(b);
+    return b;
   }
 
@@ -143,8 +128,10 @@
     //this steers our network frequency
     timeSinceLastUpdate_+=time.getDeltaTime();
-    if(timeSinceLastUpdate_>=NETWORK_PERIOD){
+    if(timeSinceLastUpdate_>=NETWORK_PERIOD)
+    {
       timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
       //     COUT(3) << ".";
-      if(client_connection.isConnected() && isSynched_){
+      if ( isConnected() && isSynched_ )
+      {
         COUT(4) << "popping partial gamestate: " << std::endl;
         packet::Gamestate *gs = gamestate.getGamestate();
@@ -159,16 +146,7 @@
       }
     }
+    sendPackets(); // flush the enet queue
     
-    ENetEvent *event;
-    // stop if the packet queue is empty
-    while(!(client_connection.queueEmpty())){
-      event = client_connection.getEvent();
-      COUT(5) << "tick packet size " << event->packet->dataLength << std::endl;
-      packet::Packet *packet = packet::Packet::createPacket(event->packet, event->peer);
-      // note: packet commits suicide here except for the GameState. That is then deleted by a GamestateHandler
-      bool b = packet->process();
-      assert(b);
-      delete event;
-    }
+    Connection::processQueue();
     if(gamestate.processGamestates())
     {
