[Orxonox-commit 3080] r7774 - code/branches/network5/src/libraries/network

scheusso at orxonox.net scheusso at orxonox.net
Fri Dec 17 11:49:09 CET 2010


Author: scheusso
Date: 2010-12-17 11:49:08 +0100 (Fri, 17 Dec 2010)
New Revision: 7774

Modified:
   code/branches/network5/src/libraries/network/ClientConnection.cc
   code/branches/network5/src/libraries/network/Connection.cc
   code/branches/network5/src/libraries/network/Connection.h
   code/branches/network5/src/libraries/network/ServerConnection.cc
Log:
some comments
enable enet packet compression


Modified: code/branches/network5/src/libraries/network/ClientConnection.cc
===================================================================
--- code/branches/network5/src/libraries/network/ClientConnection.cc	2010-12-17 10:09:14 UTC (rev 7773)
+++ code/branches/network5/src/libraries/network/ClientConnection.cc	2010-12-17 10:49:08 UTC (rev 7774)
@@ -69,13 +69,19 @@
   {
     ENetEvent event;
 
+    // create host
     this->host_ = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, NETWORK_CHANNEL_COUNT, 0, 0);
+    
     if ( this->host_ == NULL )
     {
       COUT(1) << "ClientConnection: host_ == NULL" << std::endl;
       // error handling
       return false;
     }
+    
+    // enable compression
+    this->enableCompression();
+    
     assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL );
     if (this->host_->socket4 == ENET_SOCKET_NULL)
         COUT(2) << "Warning: IPv4 Socket failed." << std::endl;

Modified: code/branches/network5/src/libraries/network/Connection.cc
===================================================================
--- code/branches/network5/src/libraries/network/Connection.cc	2010-12-17 10:09:14 UTC (rev 7773)
+++ code/branches/network5/src/libraries/network/Connection.cc	2010-12-17 10:49:08 UTC (rev 7774)
@@ -209,5 +209,11 @@
     packet::Packet *p = packet::Packet::createPacket(event->packet, event->peer);
     return p->process();
   }
+  
+  void Connection::enableCompression()
+  {
+    enet_host_compress_with_range_coder( this->host_ );
+  }
 
+
 }

Modified: code/branches/network5/src/libraries/network/Connection.h
===================================================================
--- code/branches/network5/src/libraries/network/Connection.h	2010-12-17 10:09:14 UTC (rev 7773)
+++ code/branches/network5/src/libraries/network/Connection.h	2010-12-17 10:49:08 UTC (rev 7774)
@@ -94,6 +94,8 @@
     void stopCommunicationThread();
     void communicationThread();
     virtual void disconnectPeer(ENetPeer *peer);
+    
+    void enableCompression();
 
     void processQueue();
     virtual void addPeer(ENetEvent* event)=0;

Modified: code/branches/network5/src/libraries/network/ServerConnection.cc
===================================================================
--- code/branches/network5/src/libraries/network/ServerConnection.cc	2010-12-17 10:09:14 UTC (rev 7773)
+++ code/branches/network5/src/libraries/network/ServerConnection.cc	2010-12-17 10:49:08 UTC (rev 7774)
@@ -67,12 +67,17 @@
 
   bool ServerConnection::openListener()
   {
+    // create host
     this->host_ = enet_host_create(this->bindAddress_, NETWORK_MAX_CONNECTIONS, NETWORK_CHANNEL_COUNT, 0, 0);
+    
     if ( this->host_ == NULL )
     {
         COUT(1) << "ServerConnection: host_ == NULL" << std::endl;
         return false;
     }
+    
+    // enable compression
+    this->enableCompression();
     assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL );
     if (this->host_->socket4 == ENET_SOCKET_NULL)
         COUT(2) << "Warning: IPv4 Socket failed." << std::endl;
@@ -81,6 +86,7 @@
     else
         COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;
     
+    // start communication thread
     Connection::startCommunicationThread();
 
     return true;




More information about the Orxonox-commit mailing list