Browse Source

Removed unnecessary code from Connection.

Lasse Öörni 14 years ago
parent
commit
1d3f797643
3 changed files with 7 additions and 16 deletions
  1. 2 2
      Docs/Reference.dox
  2. 4 13
      Engine/Network/Connection.cpp
  3. 1 1
      Engine/Network/Connection.h

+ 2 - 2
Docs/Reference.dox

@@ -979,9 +979,9 @@ The attribute system also supports editing by providing human-readable names.
 
 \page Network Networking
 
-The Network library provides reliable and unreliable UDP messaging using kNet. A server can be created that listens for incoming connections, and client connections can be made to the server. After connecting, code running on the server can assign the client into a scene to enable scene replication, provided that when connecting, the client also specified a blank scene that can be used.
+The Network library provides reliable and unreliable UDP messaging using kNet. A server can be created that listens for incoming connections, and client connections can be made to the server. After connecting, code running on the server can assign the client into a scene to enable scene replication, provided that when connecting, the client specified a blank scene for receiving the updates.
 
-%Scene replication is one-directional: the server always has authority and sends scene updates to the client at a fixed update rate, by default 25 FPS. The client responds by only sending controls updates (buttons, yaw and pitch + possible extra data) also at a fixed rate.
+%Scene replication is one-directional: the server always has authority and sends scene updates to the client at a fixed update rate, by default 25 FPS. The client responds by sending controls updates (buttons, yaw and pitch + possible extra data) also at a fixed rate.
 
 Bidirectional communication between the server and the client can happen either using raw network messages, which are binary-serialized data, or remote events, which operate like ordinary events, but are processed on the receiving end only. Code on the server can send messages or remote events either to one client, all clients assigned into a particular scene, or to all connected clients. In contrast the client can only send messages or remote events to the server, not directly to other clients.
 

+ 4 - 13
Engine/Network/Connection.cpp

@@ -726,8 +726,7 @@ void Connection::ProcessPackageDownload(int msgID, MemoryBuffer& msg)
             // If no further data, this is an error reply
             if (msg.IsEof())
             {
-                LOGERROR("Download of package " + download.name_ + " failed");
-                OnPackageDownloadFailed();
+                OnPackageDownloadFailed(download.name_);
                 return;
             }
             
@@ -737,8 +736,7 @@ void Connection::ProcessPackageDownload(int msgID, MemoryBuffer& msg)
                 download.file_ = new File(context_, GetSubsystem<Network>()->GetPackageCacheDir() + ToStringHex(download.checksum_) + "_" + download.name_, FILE_WRITE);
                 if (!download.file_->IsOpen())
                 {
-                    LOGERROR("Download of package " + download.name_ + " failed");
-                    OnPackageDownloadFailed();
+                    OnPackageDownloadFailed(download.name_);
                     return;
                 }
             }
@@ -754,13 +752,6 @@ void Connection::ProcessPackageDownload(int msgID, MemoryBuffer& msg)
             download.receivedFragments_.Insert(index);
             
             // Check if all fragments received
-            if (download.receivedFragments_.Size() > download.totalFragments_)
-            {
-                LOGERROR("Received extra fragments for package " + download.name_);
-                OnPackageDownloadFailed();
-                return;
-            }
-            
             if (download.receivedFragments_.Size() == download.totalFragments_)
             {
                 LOGINFO("Package " + download.name_ + " downloaded successfully");
@@ -1197,11 +1188,11 @@ void Connection::OnSceneLoadFailed()
     VariantMap eventData;
     eventData[P_CONNECTION] = (void*)this;
     SendEvent(E_NETWORKSCENELOADFAILED, eventData);
-    return;
 }
 
-void Connection::OnPackageDownloadFailed()
+void Connection::OnPackageDownloadFailed(const String& name)
 {
+    LOGERROR("Download of package " + name + " failed");
     // As one package failed, we can not join the scene in any case. Clear the downloads
     downloads_.Clear();
     OnSceneLoadFailed();

+ 1 - 1
Engine/Network/Connection.h

@@ -180,7 +180,7 @@ private:
     /// Handle scene load failure on the server or client
     void OnSceneLoadFailed();
     /// Handle a package download failure on the client
-    void OnPackageDownloadFailed();
+    void OnPackageDownloadFailed(const String& name);
     /// Handle all packages loaded successfully. Also called directly on MSG_LOADSCENE if there are none
     void OnPackagesReady();