[Orxonox-commit 3079] r7773 - in code/branches/network5/src/libraries/network: . packet

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


Author: scheusso
Date: 2010-12-17 11:09:14 +0100 (Fri, 17 Dec 2010)
New Revision: 7773

Modified:
   code/branches/network5/src/libraries/network/ClientConnection.cc
   code/branches/network5/src/libraries/network/GamestateManager.cc
   code/branches/network5/src/libraries/network/NetworkPrereqs.h
   code/branches/network5/src/libraries/network/Server.cc
   code/branches/network5/src/libraries/network/ServerConnection.cc
   code/branches/network5/src/libraries/network/packet/Packet.cc
Log:
small fix (ensure correct termination of communicationThread)


Modified: code/branches/network5/src/libraries/network/ClientConnection.cc
===================================================================
--- code/branches/network5/src/libraries/network/ClientConnection.cc	2010-12-17 09:41:24 UTC (rev 7772)
+++ code/branches/network5/src/libraries/network/ClientConnection.cc	2010-12-17 10:09:14 UTC (rev 7773)
@@ -38,7 +38,6 @@
   const unsigned int NETWORK_CLIENT_WAIT_TIME = 1;
   const unsigned int NETWORK_CLIENT_CONNECTION_TIMEOUT = 3000; //millisecs
   const unsigned int NETWORK_CLIENT_MAX_CONNECTIONS = 1;
-  const unsigned int NETWORK_CLIENT_CHANNELS = 1;
 
 
   ClientConnection::ClientConnection():
@@ -70,7 +69,7 @@
   {
     ENetEvent event;
 
-    this->host_ = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0, 0);
+    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;
@@ -85,7 +84,7 @@
     else
         COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;
 
-    this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CLIENT_CHANNELS, 0);
+    this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CHANNEL_COUNT, 0);
     if ( this->server_==NULL )
     {
       COUT(1) << "ClientConnection: server_ == NULL" << std::endl;
@@ -154,6 +153,7 @@
     this->established_=false;
     COUT(1) << "Received disconnect Packet from Server!" << endl;
         // server closed the connection
+    this->stopCommunicationThread();
     this->connectionClosed();
   }
 

Modified: code/branches/network5/src/libraries/network/GamestateManager.cc
===================================================================
--- code/branches/network5/src/libraries/network/GamestateManager.cc	2010-12-17 09:41:24 UTC (rev 7772)
+++ code/branches/network5/src/libraries/network/GamestateManager.cc	2010-12-17 10:09:14 UTC (rev 7773)
@@ -215,8 +215,8 @@
     }
 
 
-    bool b = gs->compressData();
-    assert(b);
+//     bool b = gs->compressData();
+//     assert(b);
       clock.capture();
       COUT(4) << "diff and compress time: " << clock.getDeltaTime() << endl;
 //     COUT(5) << "sending gamestate with id " << gs->getID();

Modified: code/branches/network5/src/libraries/network/NetworkPrereqs.h
===================================================================
--- code/branches/network5/src/libraries/network/NetworkPrereqs.h	2010-12-17 09:41:24 UTC (rev 7772)
+++ code/branches/network5/src/libraries/network/NetworkPrereqs.h	2010-12-17 10:09:14 UTC (rev 7773)
@@ -67,10 +67,11 @@
   static const unsigned int CLIENTID_UNKNOWN          = static_cast<unsigned int>(-2);
   extern const char* LAN_DISCOVERY_MESSAGE;
   extern const char* LAN_DISCOVERY_ACK;
-  static const unsigned int LAN_DISCOVERY_PORT        = 55557;
-  static const unsigned int NETWORK_PEER_ID_SERVER    = 0;
-  static const unsigned int NETWORK_CHANNEL_DEFAULT   = 0;
-  static const unsigned int NETWORK_CHANNEL_RELIABLE  = 1;
+  static const unsigned int LAN_DISCOVERY_PORT          = 55557;
+  static const unsigned int NETWORK_PEER_ID_SERVER      = 0;
+  static const unsigned int NETWORK_CHANNEL_DEFAULT     = 0;
+  static const unsigned int NETWORK_CHANNEL_UNRELIABLE  = 1;
+  static const unsigned int NETWORK_CHANNEL_COUNT       = 2;
 }
 
 //-----------------------------------------------------------------------

Modified: code/branches/network5/src/libraries/network/Server.cc
===================================================================
--- code/branches/network5/src/libraries/network/Server.cc	2010-12-17 09:41:24 UTC (rev 7772)
+++ code/branches/network5/src/libraries/network/Server.cc	2010-12-17 10:09:14 UTC (rev 7773)
@@ -424,8 +424,8 @@
     b = g->collectData(0,0x1);
     if(!b)
       return false; //no data for the client
-    b = g->compressData();
-    assert(b);
+//     b = g->compressData();
+//     assert(b);
     b = g->send();
     assert(b);
     return true;

Modified: code/branches/network5/src/libraries/network/ServerConnection.cc
===================================================================
--- code/branches/network5/src/libraries/network/ServerConnection.cc	2010-12-17 09:41:24 UTC (rev 7772)
+++ code/branches/network5/src/libraries/network/ServerConnection.cc	2010-12-17 10:09:14 UTC (rev 7773)
@@ -67,7 +67,7 @@
 
   bool ServerConnection::openListener()
   {
-    this->host_ = enet_host_create(this->bindAddress_, NETWORK_MAX_CONNECTIONS, 0, 0, 0);
+    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;
@@ -90,6 +90,7 @@
   {
     this->bListening_=false;
     disconnectClients();
+    Connection::stopCommunicationThread();
     enet_host_destroy(this->host_);
     return true;
   }

Modified: code/branches/network5/src/libraries/network/packet/Packet.cc
===================================================================
--- code/branches/network5/src/libraries/network/packet/Packet.cc	2010-12-17 09:41:24 UTC (rev 7772)
+++ code/branches/network5/src/libraries/network/packet/Packet.cc	2010-12-17 10:09:14 UTC (rev 7773)
@@ -168,9 +168,9 @@
 //  ENetPacket *temp = enetPacket_;
 //  enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet
   if( this->flags_ & PacketFlag::Reliable )
-    Host::addPacket( enetPacket_, clientID_, 0);
+    Host::addPacket( enetPacket_, clientID_, NETWORK_CHANNEL_DEFAULT);
   else
-    Host::addPacket( enetPacket_, clientID_, 0);
+    Host::addPacket( enetPacket_, clientID_, NETWORK_CHANNEL_UNRELIABLE);
   return true;
 }
 




More information about the Orxonox-commit mailing list