[Orxonox-commit 1130] r5851 - code/branches/core5/src/libraries/network

scheusso at orxonox.net scheusso at orxonox.net
Thu Oct 1 16:40:28 CEST 2009


Author: scheusso
Date: 2009-10-01 16:40:28 +0200 (Thu, 01 Oct 2009)
New Revision: 5851

Modified:
   code/branches/core5/src/libraries/network/ClientConnection.cc
   code/branches/core5/src/libraries/network/ClientConnection.h
   code/branches/core5/src/libraries/network/Connection.cc
   code/branches/core5/src/libraries/network/Connection.h
   code/branches/core5/src/libraries/network/Server.cc
   code/branches/core5/src/libraries/network/Server.h
   code/branches/core5/src/libraries/network/ServerConnection.cc
   code/branches/core5/src/libraries/network/ServerConnection.h
Log:
cleaned up a little bit in connection handling


Modified: code/branches/core5/src/libraries/network/ClientConnection.cc
===================================================================
--- code/branches/core5/src/libraries/network/ClientConnection.cc	2009-10-01 09:44:53 UTC (rev 5850)
+++ code/branches/core5/src/libraries/network/ClientConnection.cc	2009-10-01 14:40:28 UTC (rev 5851)
@@ -132,11 +132,11 @@
     return Connection::addPacket( packet, this->server_ );
   }
 
-  void ClientConnection::addClient(ENetEvent* event)
+  void ClientConnection::addPeer(ENetEvent* event)
   {
     assert(0);
   }
-  void ClientConnection::disconnectPeer(ENetEvent* event)
+  void ClientConnection::removePeer(ENetEvent* event)
   {
     this->established_=false;
     COUT(1) << "Received disconnect Packet from Server!" << endl;

Modified: code/branches/core5/src/libraries/network/ClientConnection.h
===================================================================
--- code/branches/core5/src/libraries/network/ClientConnection.h	2009-10-01 09:44:53 UTC (rev 5850)
+++ code/branches/core5/src/libraries/network/ClientConnection.h	2009-10-01 14:40:28 UTC (rev 5851)
@@ -53,8 +53,8 @@
     bool addPacket(ENetPacket *packet);
     inline bool isConnected(){ return this->established_; }
   private:
-    virtual void addClient(ENetEvent* event);
-    virtual void disconnectPeer(ENetEvent* event);
+    virtual void addPeer(ENetEvent* event);
+    virtual void removePeer(ENetEvent* event);
     
     bool disconnectConnection();
     // enet stuff

Modified: code/branches/core5/src/libraries/network/Connection.cc
===================================================================
--- code/branches/core5/src/libraries/network/Connection.cc	2009-10-01 09:44:53 UTC (rev 5850)
+++ code/branches/core5/src/libraries/network/Connection.cc	2009-10-01 14:40:28 UTC (rev 5851)
@@ -82,10 +82,10 @@
       switch(event.type){
         // log handling ================
         case ENET_EVENT_TYPE_CONNECT:
-          addClient( &event );
+          addPeer( &event );
           break;
         case ENET_EVENT_TYPE_DISCONNECT:
-          disconnectPeer( &event );
+          removePeer( &event );
           break;
         case ENET_EVENT_TYPE_RECEIVE:
           processPacket( &event );

Modified: code/branches/core5/src/libraries/network/Connection.h
===================================================================
--- code/branches/core5/src/libraries/network/Connection.h	2009-10-01 09:44:53 UTC (rev 5850)
+++ code/branches/core5/src/libraries/network/Connection.h	2009-10-01 14:40:28 UTC (rev 5851)
@@ -66,8 +66,8 @@
     virtual void disconnectPeer(ENetPeer *peer);
     
     void processQueue();
-    virtual void addClient(ENetEvent* event)=0;
-    virtual void disconnectPeer(ENetEvent* event)=0;
+    virtual void addPeer(ENetEvent* event)=0;
+    virtual void removePeer(ENetEvent* event)=0;
     virtual bool processPacket(ENetEvent* event);
     
     ENetHost *host_;

Modified: code/branches/core5/src/libraries/network/Server.cc
===================================================================
--- code/branches/core5/src/libraries/network/Server.cc	2009-10-01 09:44:53 UTC (rev 5850)
+++ code/branches/core5/src/libraries/network/Server.cc	2009-10-01 14:40:28 UTC (rev 5851)
@@ -269,7 +269,7 @@
   }
 
 
-  void Server::addClient(ENetEvent *event){
+  void Server::addPeer(ENetEvent *event){
     static unsigned int newid=1;
 
     COUT(2) << "Server: adding client" << std::endl;
@@ -289,6 +289,20 @@
     createClient(temp->getID());
 }
 
+  void Server::removePeer(ENetEvent *event)
+  {
+    COUT(4) << "removing client from list" << std::endl;
+    ClientInformation *client = ClientInformation::findClient(&event->peer->address);
+    if(!client)
+      return;
+    else
+    {
+      //ServerConnection::disconnectClient( client );
+      ClientConnectionListener::broadcastClientDisconnected( client->getID() );
+      delete client;
+    }
+  }
+
   bool Server::createClient(int clientID){
     ClientInformation *temp = ClientInformation::findClient(clientID);
     if(!temp){

Modified: code/branches/core5/src/libraries/network/Server.h
===================================================================
--- code/branches/core5/src/libraries/network/Server.h	2009-10-01 09:44:53 UTC (rev 5850)
+++ code/branches/core5/src/libraries/network/Server.h	2009-10-01 14:40:28 UTC (rev 5851)
@@ -64,7 +64,9 @@
     unsigned int shipID(){return 0;}
     unsigned int playerID(){return 0;}
     
-    void addClient(ENetEvent *event);
+    void addPeer(ENetEvent *event);
+    void removePeer(ENetEvent *event);
+    
     bool createClient(int clientID);
     void disconnectClient( ClientInformation *client);
     bool processPacket( ENetPacket *packet, ENetPeer *peer );

Modified: code/branches/core5/src/libraries/network/ServerConnection.cc
===================================================================
--- code/branches/core5/src/libraries/network/ServerConnection.cc	2009-10-01 09:44:53 UTC (rev 5850)
+++ code/branches/core5/src/libraries/network/ServerConnection.cc	2009-10-01 14:40:28 UTC (rev 5851)
@@ -104,16 +104,6 @@
     Connection::disconnectPeer( client->getPeer() );
   }
   
-  void ServerConnection::disconnectPeer( ENetEvent* event )
-  {
-    COUT(4) << "removing client from list" << std::endl;
-    ClientInformation *client = ClientInformation::findClient(&event->peer->address);
-    if(!client)
-      return;
-    else
-      ServerConnection::disconnectClient( client );
-  }
-  
   void ServerConnection::disconnectClient(int clientID){
     ClientInformation *client = ClientInformation::findClient(clientID);
     if(client)

Modified: code/branches/core5/src/libraries/network/ServerConnection.h
===================================================================
--- code/branches/core5/src/libraries/network/ServerConnection.h	2009-10-01 09:44:53 UTC (rev 5850)
+++ code/branches/core5/src/libraries/network/ServerConnection.h	2009-10-01 14:40:28 UTC (rev 5851)
@@ -58,7 +58,6 @@
     static bool addPacket(ENetPacket *packet, unsigned int ID);
     static bool addPacketAll(ENetPacket *packet);
     virtual void disconnectClient(ClientInformation *client);
-    virtual void disconnectPeer( ENetEvent* event );
     void disconnectClient(int clientID);
   protected:
     ServerConnection();




More information about the Orxonox-commit mailing list