Browse Source

Removed kNet message priority sorting to improve CPU performance when sending a high volume of network messages.

Lasse Öörni 13 years ago
parent
commit
e0571d46eb

+ 2 - 4
Docs/ScriptAPI.dox

@@ -206,8 +206,6 @@
 - uint DD_SOURCE
 - uint DD_SOURCE
 - uint DD_TARGET
 - uint DD_TARGET
 - uint DD_SOURCE_AND_TARGET
 - uint DD_SOURCE_AND_TARGET
-- uint NET_LOW_PRIORITY
-- uint NET_HIGH_PRIORITY
 - uint DEBUGHUD_SHOW_NONE
 - uint DEBUGHUD_SHOW_NONE
 - uint DEBUGHUD_SHOW_STATS
 - uint DEBUGHUD_SHOW_STATS
 - uint DEBUGHUD_SHOW_MODE
 - uint DEBUGHUD_SHOW_MODE
@@ -3868,7 +3866,7 @@ Properties:<br>
 Connection
 Connection
 
 
 Methods:<br>
 Methods:<br>
-- void SendMessage(int, bool, bool, const VectorBuffer&, uint arg4 = 0, uint arg5 = 0)
+- void SendMessage(int, bool, bool, const VectorBuffer&, uint arg4 = 0)
 - void SendRemoteEvent(const String&, bool, const VariantMap& arg2 = VariantMap ( ))
 - void SendRemoteEvent(const String&, bool, const VariantMap& arg2 = VariantMap ( ))
 - void SendRemoteEvent(Node@, const String&, bool, const VariantMap& arg3 = VariantMap ( ))
 - void SendRemoteEvent(Node@, const String&, bool, const VariantMap& arg3 = VariantMap ( ))
 - void Disconnect(int arg0 = 0)
 - void Disconnect(int arg0 = 0)
@@ -3900,7 +3898,7 @@ Methods:<br>
 - void Disconnect(int arg0 = 0)
 - void Disconnect(int arg0 = 0)
 - bool StartServer(uint16)
 - bool StartServer(uint16)
 - void StopServer()
 - void StopServer()
-- void BroadcastMessage(int, bool, bool, const VectorBuffer&, uint arg4 = 0, uint arg5 = 0)
+- void BroadcastMessage(int, bool, bool, const VectorBuffer&, uint arg4 = 0)
 - void BroadcastRemoteEvent(const String&, bool, const VariantMap& arg2 = VariantMap ( ))
 - void BroadcastRemoteEvent(const String&, bool, const VariantMap& arg2 = VariantMap ( ))
 - void BroadcastRemoteEvent(Scene@, const String&, bool, const VariantMap& arg3 = VariantMap ( ))
 - void BroadcastRemoteEvent(Scene@, const String&, bool, const VariantMap& arg3 = VariantMap ( ))
 - void BroadcastRemoteEvent(Node@, const String&, bool, const VariantMap& arg3 = VariantMap ( ))
 - void BroadcastRemoteEvent(Node@, const String&, bool, const VariantMap& arg3 = VariantMap ( ))

+ 2 - 5
Engine/Engine/NetworkAPI.cpp

@@ -85,11 +85,8 @@ void SendRemoteNodeEvent(Node* receiver, const String& eventType, bool inOrder,
 
 
 static void RegisterConnection(asIScriptEngine* engine)
 static void RegisterConnection(asIScriptEngine* engine)
 {
 {
-    engine->RegisterGlobalProperty("uint NET_LOW_PRIORITY", (void*)&NET_LOW_PRIORITY);
-    engine->RegisterGlobalProperty("uint NET_HIGH_PRIORITY", (void*)&NET_HIGH_PRIORITY);
-    
     RegisterObject<Connection>(engine, "Connection");
     RegisterObject<Connection>(engine, "Connection");
-    engine->RegisterObjectMethod("Connection", "void SendMessage(int, bool, bool, const VectorBuffer&in, uint priority = 0, uint contentID = 0)", asMETHODPR(Connection, SendMessage, (int, bool, bool, const VectorBuffer&, unsigned, unsigned), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Connection", "void SendMessage(int, bool, bool, const VectorBuffer&in, uint contentID = 0)", asMETHODPR(Connection, SendMessage, (int, bool, bool, const VectorBuffer&, unsigned), void), asCALL_THISCALL);
     engine->RegisterObjectMethod("Connection", "void SendRemoteEvent(const String&in, bool, const VariantMap&in eventData = VariantMap())", asFUNCTION(SendRemoteEvent), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Connection", "void SendRemoteEvent(const String&in, bool, const VariantMap&in eventData = VariantMap())", asFUNCTION(SendRemoteEvent), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Connection", "void SendRemoteEvent(Node@+, const String&in, bool, const VariantMap&in eventData = VariantMap())", asFUNCTION(SendRemoteNodeEvent), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Connection", "void SendRemoteEvent(Node@+, const String&in, bool, const VariantMap&in eventData = VariantMap())", asFUNCTION(SendRemoteNodeEvent), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Connection", "void Disconnect(int waitMSec = 0)", asMETHOD(Connection, Disconnect), asCALL_THISCALL);
     engine->RegisterObjectMethod("Connection", "void Disconnect(int waitMSec = 0)", asMETHOD(Connection, Disconnect), asCALL_THISCALL);
@@ -189,7 +186,7 @@ void RegisterNetwork(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Network", "void Disconnect(int waitMSec = 0)", asMETHOD(Network, Disconnect), asCALL_THISCALL);
     engine->RegisterObjectMethod("Network", "void Disconnect(int waitMSec = 0)", asMETHOD(Network, Disconnect), asCALL_THISCALL);
     engine->RegisterObjectMethod("Network", "bool StartServer(uint16)", asMETHOD(Network, StartServer), asCALL_THISCALL);
     engine->RegisterObjectMethod("Network", "bool StartServer(uint16)", asMETHOD(Network, StartServer), asCALL_THISCALL);
     engine->RegisterObjectMethod("Network", "void StopServer()", asMETHOD(Network, StopServer), asCALL_THISCALL);
     engine->RegisterObjectMethod("Network", "void StopServer()", asMETHOD(Network, StopServer), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Network", "void BroadcastMessage(int, bool, bool, const VectorBuffer&in, uint priority = 0, uint contentID = 0)", asMETHODPR(Network, BroadcastMessage, (int, bool, bool, const VectorBuffer&, unsigned, unsigned), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Network", "void BroadcastMessage(int, bool, bool, const VectorBuffer&in, uint contentID = 0)", asMETHODPR(Network, BroadcastMessage, (int, bool, bool, const VectorBuffer&, unsigned), void), asCALL_THISCALL);
     engine->RegisterObjectMethod("Network", "void BroadcastRemoteEvent(const String&in, bool, const VariantMap&in eventData = VariantMap())", asFUNCTION(NetworkBroadcastRemoteEvent), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Network", "void BroadcastRemoteEvent(const String&in, bool, const VariantMap&in eventData = VariantMap())", asFUNCTION(NetworkBroadcastRemoteEvent), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Network", "void BroadcastRemoteEvent(Scene@+, const String&in, bool, const VariantMap&in eventData = VariantMap())", asFUNCTION(NetworkBroadcastRemoteSceneEvent), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Network", "void BroadcastRemoteEvent(Scene@+, const String&in, bool, const VariantMap&in eventData = VariantMap())", asFUNCTION(NetworkBroadcastRemoteSceneEvent), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Network", "void BroadcastRemoteEvent(Node@+, const String&in, bool, const VariantMap&in eventData = VariantMap())", asFUNCTION(NetworkBroadcastRemoteNodeEvent), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Network", "void BroadcastRemoteEvent(Node@+, const String&in, bool, const VariantMap&in eventData = VariantMap())", asFUNCTION(NetworkBroadcastRemoteNodeEvent), asCALL_CDECL_OBJLAST);

+ 24 - 25
Engine/Network/Connection.cpp

@@ -78,13 +78,13 @@ Connection::~Connection()
     SetScene(0);
     SetScene(0);
 }
 }
 
 
-void Connection::SendMessage(int msgID, bool reliable, bool inOrder, const VectorBuffer& msg, unsigned priority, unsigned contentID)
+void Connection::SendMessage(int msgID, bool reliable, bool inOrder, const VectorBuffer& msg, unsigned contentID)
 {
 {
-    SendMessage(msgID, reliable, inOrder, msg.GetData(), msg.GetSize(), priority, contentID);
+    SendMessage(msgID, reliable, inOrder, msg.GetData(), msg.GetSize(), contentID);
 }
 }
 
 
 void Connection::SendMessage(int msgID, bool reliable, bool inOrder, const unsigned char* data, unsigned numBytes,
 void Connection::SendMessage(int msgID, bool reliable, bool inOrder, const unsigned char* data, unsigned numBytes,
-    unsigned priority, unsigned contentID)
+    unsigned contentID)
 {
 {
     // Make sure not to use kNet internal message ID's
     // Make sure not to use kNet internal message ID's
     if (msgID <= 0x4 || msgID >= 0x3ffffffe)
     if (msgID <= 0x4 || msgID >= 0x3ffffffe)
@@ -93,7 +93,7 @@ void Connection::SendMessage(int msgID, bool reliable, bool inOrder, const unsig
         return;
         return;
     }
     }
     
     
-    connection_->SendMessage(msgID, reliable, inOrder, priority, contentID, (const char*)data, numBytes);
+    connection_->SendMessage(msgID, reliable, inOrder, 0, contentID, (const char*)data, numBytes);
 }
 }
 
 
 void Connection::SendRemoteEvent(StringHash eventType, bool inOrder, const VariantMap& eventData)
 void Connection::SendRemoteEvent(StringHash eventType, bool inOrder, const VariantMap& eventData)
@@ -176,7 +176,7 @@ void Connection::SetScene(Scene* newScene)
             msg_.WriteUInt(package->GetTotalSize());
             msg_.WriteUInt(package->GetTotalSize());
             msg_.WriteUInt(package->GetChecksum());
             msg_.WriteUInt(package->GetChecksum());
         }
         }
-        SendMessage(MSG_LOADSCENE, true, true, msg_, NET_HIGH_PRIORITY);
+        SendMessage(MSG_LOADSCENE, true, true, msg_);
     }
     }
     else
     else
     {
     {
@@ -249,7 +249,7 @@ void Connection::SendServerUpdate()
                 // Note: we will send MSG_REMOVENODE redundantly for each node in the hierarchy, even if removing the root node
                 // Note: we will send MSG_REMOVENODE redundantly for each node in the hierarchy, even if removing the root node
                 // would be enough. However, this may be better due to the client not possibly having updated parenting
                 // would be enough. However, this may be better due to the client not possibly having updated parenting
                 // information at the time of receiving this message
                 // information at the time of receiving this message
-                SendMessage(MSG_REMOVENODE, true, true, msg_, NET_HIGH_PRIORITY);
+                SendMessage(MSG_REMOVENODE, true, true, msg_);
                 sceneState_.nodeStates_.Erase(id);
                 sceneState_.nodeStates_.Erase(id);
             }
             }
         }
         }
@@ -267,7 +267,7 @@ void Connection::SendClientUpdate()
     msg_.WriteFloat(controls_.pitch_);
     msg_.WriteFloat(controls_.pitch_);
     msg_.WriteVariantMap(controls_.extraData_);
     msg_.WriteVariantMap(controls_.extraData_);
     msg_.WriteVector3(position_);
     msg_.WriteVector3(position_);
-    SendMessage(MSG_CONTROLS, false, false, msg_, NET_HIGH_PRIORITY, CONTROLS_CONTENT_ID);
+    SendMessage(MSG_CONTROLS, false, false, msg_, CONTROLS_CONTENT_ID);
 }
 }
 
 
 void Connection::SendRemoteEvents()
 void Connection::SendRemoteEvents()
@@ -293,14 +293,14 @@ void Connection::SendRemoteEvents()
         {
         {
             msg_.WriteStringHash(i->eventType_);
             msg_.WriteStringHash(i->eventType_);
             msg_.WriteVariantMap(i->eventData_);
             msg_.WriteVariantMap(i->eventData_);
-            SendMessage(MSG_REMOTEEVENT, true, i->inOrder_, msg_, NET_HIGH_PRIORITY);
+            SendMessage(MSG_REMOTEEVENT, true, i->inOrder_, msg_);
         }
         }
         else
         else
         {
         {
             msg_.WriteNetID(i->receiverID_);
             msg_.WriteNetID(i->receiverID_);
             msg_.WriteStringHash(i->eventType_);
             msg_.WriteStringHash(i->eventType_);
             msg_.WriteVariantMap(i->eventData_);
             msg_.WriteVariantMap(i->eventData_);
-            SendMessage(MSG_REMOTENODEEVENT, true, i->inOrder_, msg_, NET_HIGH_PRIORITY);
+            SendMessage(MSG_REMOTENODEEVENT, true, i->inOrder_, msg_);
         }
         }
     }
     }
     
     
@@ -324,7 +324,7 @@ void Connection::SendPackages()
             msg_.WriteStringHash(current->first_);
             msg_.WriteStringHash(current->first_);
             msg_.WriteUInt(upload.fragment_++);
             msg_.WriteUInt(upload.fragment_++);
             msg_.Write(buffer, fragmentSize);
             msg_.Write(buffer, fragmentSize);
-            SendMessage(MSG_PACKAGEDATA, true, false, msg_, NET_LOW_PRIORITY);
+            SendMessage(MSG_PACKAGEDATA, true, false, msg_);
             
             
             // Check if upload finished
             // Check if upload finished
             if (upload.fragment_ == upload.totalFragments_)
             if (upload.fragment_ == upload.totalFragments_)
@@ -387,8 +387,7 @@ void Connection::ProcessLoadScene(int msgID, MemoryBuffer& msg)
     // Store the scene file name we need to eventually load
     // Store the scene file name we need to eventually load
     sceneFileName_ = msg.ReadString();
     sceneFileName_ = msg.ReadString();
     
     
-    // Clear previous scene content, pending latest data, and package downloads if any
-    scene_->Clear();
+    // Clear previous pending latest data and package downloads if any
     nodeLatestData_.Clear();
     nodeLatestData_.Clear();
     componentLatestData_.Clear();
     componentLatestData_.Clear();
     downloads_.Clear();
     downloads_.Clear();
@@ -818,7 +817,7 @@ void Connection::ProcessPackageDownload(int msgID, MemoryBuffer& msg)
                     LOGINFO("Requesting package " + nextDownload.name_ + " from server");
                     LOGINFO("Requesting package " + nextDownload.name_ + " from server");
                     msg_.Clear();
                     msg_.Clear();
                     msg_.WriteString(nextDownload.name_);
                     msg_.WriteString(nextDownload.name_);
-                    SendMessage(MSG_REQUESTPACKAGE, true, true, msg_, NET_HIGH_PRIORITY);
+                    SendMessage(MSG_REQUESTPACKAGE, true, true, msg_);
                     nextDownload.initiated_ = true;
                     nextDownload.initiated_ = true;
                 }
                 }
             }
             }
@@ -887,7 +886,7 @@ void Connection::ProcessSceneLoaded(int msgID, MemoryBuffer& msg)
     {
     {
         LOGINFO("Scene checksum error from client " + ToString());
         LOGINFO("Scene checksum error from client " + ToString());
         msg_.Clear();
         msg_.Clear();
-        SendMessage(MSG_SCENECHECKSUMERROR, true, true, msg_, NET_HIGH_PRIORITY);
+        SendMessage(MSG_SCENECHECKSUMERROR, true, true, msg_);
         OnSceneLoadFailed();
         OnSceneLoadFailed();
     }
     }
     else
     else
@@ -1007,7 +1006,7 @@ void Connection::HandleAsyncLoadFinished(StringHash eventType, VariantMap& event
     
     
     msg_.Clear();
     msg_.Clear();
     msg_.WriteUInt(scene_->GetChecksum());
     msg_.WriteUInt(scene_->GetChecksum());
-    SendMessage(MSG_SCENELOADED, true, true, msg_, NET_HIGH_PRIORITY);
+    SendMessage(MSG_SCENELOADED, true, true, msg_);
 }
 }
 
 
 void Connection::ProcessNode(Node* node)
 void Connection::ProcessNode(Node* node)
@@ -1077,7 +1076,7 @@ void Connection::ProcessNewNode(Node* node)
         component->WriteInitialDeltaUpdate(msg_);
         component->WriteInitialDeltaUpdate(msg_);
     }
     }
     
     
-    SendMessage(MSG_CREATENODE, true, true, msg_, NET_HIGH_PRIORITY);
+    SendMessage(MSG_CREATENODE, true, true, msg_);
     
     
     nodeState.markedDirty_ = false;
     nodeState.markedDirty_ = false;
     sceneState_.dirtyNodes_.Erase(node->GetID());
     sceneState_.dirtyNodes_.Erase(node->GetID());
@@ -1117,7 +1116,7 @@ void Connection::ProcessExistingNode(Node* node, NodeReplicationState& nodeState
             msg_.WriteNetID(node->GetID());
             msg_.WriteNetID(node->GetID());
             node->WriteLatestDataUpdate(msg_);
             node->WriteLatestDataUpdate(msg_);
             
             
-            SendMessage(MSG_NODELATESTDATA, true, false, msg_, NET_HIGH_PRIORITY, node->GetID());
+            SendMessage(MSG_NODELATESTDATA, true, false, msg_, node->GetID());
         }
         }
         
         
         // Send deltaupdate if remaining dirty bits, or vars have changed
         // Send deltaupdate if remaining dirty bits, or vars have changed
@@ -1147,7 +1146,7 @@ void Connection::ProcessExistingNode(Node* node, NodeReplicationState& nodeState
                 }
                 }
             }
             }
             
             
-            SendMessage(MSG_NODEDELTAUPDATE, true, true, msg_, NET_HIGH_PRIORITY);
+            SendMessage(MSG_NODEDELTAUPDATE, true, true, msg_);
             
             
             nodeState.dirtyAttributes_.ClearAll();
             nodeState.dirtyAttributes_.ClearAll();
             nodeState.dirtyVars_.Clear();
             nodeState.dirtyVars_.Clear();
@@ -1179,7 +1178,7 @@ void Connection::ProcessExistingNode(Node* node, NodeReplicationState& nodeState
             msg_.WriteNetID(component->GetID());
             msg_.WriteNetID(component->GetID());
             component->WriteInitialDeltaUpdate(msg_);
             component->WriteInitialDeltaUpdate(msg_);
             
             
-            SendMessage(MSG_CREATECOMPONENT, true, true, msg_, NET_HIGH_PRIORITY);
+            SendMessage(MSG_CREATECOMPONENT, true, true, msg_);
         }
         }
         else
         else
         {
         {
@@ -1209,7 +1208,7 @@ void Connection::ProcessExistingNode(Node* node, NodeReplicationState& nodeState
                     msg_.WriteNetID(component->GetID());
                     msg_.WriteNetID(component->GetID());
                     component->WriteLatestDataUpdate(msg_);
                     component->WriteLatestDataUpdate(msg_);
                     
                     
-                    SendMessage(MSG_COMPONENTLATESTDATA, true, false, msg_, NET_HIGH_PRIORITY, component->GetID());
+                    SendMessage(MSG_COMPONENTLATESTDATA, true, false, msg_, component->GetID());
                 }
                 }
                 
                 
                 // Send deltaupdate if remaining dirty bits, or vars have changed
                 // Send deltaupdate if remaining dirty bits, or vars have changed
@@ -1219,7 +1218,7 @@ void Connection::ProcessExistingNode(Node* node, NodeReplicationState& nodeState
                     msg_.WriteNetID(component->GetID());
                     msg_.WriteNetID(component->GetID());
                     component->WriteDeltaUpdate(msg_, componentState.dirtyAttributes_);
                     component->WriteDeltaUpdate(msg_, componentState.dirtyAttributes_);
                     
                     
-                    SendMessage(MSG_COMPONENTDELTAUPDATE, true, true, msg_, NET_HIGH_PRIORITY);
+                    SendMessage(MSG_COMPONENTDELTAUPDATE, true, true, msg_);
                     
                     
                     componentState.dirtyAttributes_.ClearAll();
                     componentState.dirtyAttributes_.ClearAll();
                 }
                 }
@@ -1237,7 +1236,7 @@ void Connection::ProcessExistingNode(Node* node, NodeReplicationState& nodeState
             msg_.Clear();
             msg_.Clear();
             msg_.WriteNetID(current->first_);
             msg_.WriteNetID(current->first_);
             
             
-            SendMessage(MSG_REMOVECOMPONENT, true, true, msg_, NET_HIGH_PRIORITY);
+            SendMessage(MSG_REMOVECOMPONENT, true, true, msg_);
             nodeState.componentStates_.Erase(current);
             nodeState.componentStates_.Erase(current);
         }
         }
     }
     }
@@ -1263,7 +1262,7 @@ void Connection::RequestPackage(const String& name, unsigned fileSize, unsigned
         LOGINFO("Requesting package " + name + " from server");
         LOGINFO("Requesting package " + name + " from server");
         msg_.Clear();
         msg_.Clear();
         msg_.WriteString(name);
         msg_.WriteString(name);
-        SendMessage(MSG_REQUESTPACKAGE, true, true, msg_, NET_HIGH_PRIORITY);
+        SendMessage(MSG_REQUESTPACKAGE, true, true, msg_);
         download.initiated_ = true;
         download.initiated_ = true;
     }
     }
 }
 }
@@ -1272,7 +1271,7 @@ void Connection::SendPackageError(const String& name)
 {
 {
     msg_.Clear();
     msg_.Clear();
     msg_.WriteStringHash(StringHash(name));
     msg_.WriteStringHash(StringHash(name));
-    SendMessage(MSG_PACKAGEDATA, true, false, msg_, NET_HIGH_PRIORITY);
+    SendMessage(MSG_PACKAGEDATA, true, false, msg_);
 }
 }
 
 
 void Connection::OnSceneLoadFailed()
 void Connection::OnSceneLoadFailed()
@@ -1307,7 +1306,7 @@ void Connection::OnPackagesReady()
         // If filename is empty, can send the scene loaded reply immediately
         // If filename is empty, can send the scene loaded reply immediately
         msg_.Clear();
         msg_.Clear();
         msg_.WriteUInt(scene_->GetChecksum());
         msg_.WriteUInt(scene_->GetChecksum());
-        SendMessage(MSG_SCENELOADED, true, true, msg_, NET_HIGH_PRIORITY);
+        SendMessage(MSG_SCENELOADED, true, true, msg_);
     }
     }
     else
     else
     {
     {

+ 2 - 2
Engine/Network/Connection.h

@@ -102,9 +102,9 @@ public:
     ~Connection();
     ~Connection();
     
     
     /// Send a message.
     /// Send a message.
-    void SendMessage(int msgID, bool reliable, bool inOrder, const VectorBuffer& msg, unsigned priority = 0, unsigned contentID = 0);
+    void SendMessage(int msgID, bool reliable, bool inOrder, const VectorBuffer& msg, unsigned contentID = 0);
     /// Send a message.
     /// Send a message.
-    void SendMessage(int msgID, bool reliable, bool inOrder, const unsigned char* data, unsigned numBytes, unsigned priority = 0, unsigned contentID = 0);
+    void SendMessage(int msgID, bool reliable, bool inOrder, const unsigned char* data, unsigned numBytes, unsigned contentID = 0);
     /// Send a remote event.
     /// Send a remote event.
     void SendRemoteEvent(StringHash eventType, bool inOrder, const VariantMap& eventData = VariantMap());
     void SendRemoteEvent(StringHash eventType, bool inOrder, const VariantMap& eventData = VariantMap());
     /// Send a remote node event.
     /// Send a remote node event.

+ 5 - 6
Engine/Network/Network.cpp

@@ -261,14 +261,13 @@ void Network::StopServer()
     LOGINFO("Stopped server");
     LOGINFO("Stopped server");
 }
 }
 
 
-void Network::BroadcastMessage(int msgID, bool reliable, bool inOrder, const VectorBuffer& msg, unsigned priority,
-    unsigned contentID)
+void Network::BroadcastMessage(int msgID, bool reliable, bool inOrder, const VectorBuffer& msg, unsigned contentID)
 {
 {
-    BroadcastMessage(msgID, reliable, inOrder, msg.GetData(), msg.GetSize(), priority, contentID);
+    BroadcastMessage(msgID, reliable, inOrder, msg.GetData(), msg.GetSize(), contentID);
 }
 }
 
 
 void Network::BroadcastMessage(int msgID, bool reliable, bool inOrder, const unsigned char* data, unsigned numBytes,
 void Network::BroadcastMessage(int msgID, bool reliable, bool inOrder, const unsigned char* data, unsigned numBytes,
-    unsigned priority, unsigned contentID)
+    unsigned contentID)
 {
 {
    // Make sure not to use kNet internal message ID's
    // Make sure not to use kNet internal message ID's
     if (msgID <= 0x4 || msgID >= 0x3ffffffe)
     if (msgID <= 0x4 || msgID >= 0x3ffffffe)
@@ -279,7 +278,7 @@ void Network::BroadcastMessage(int msgID, bool reliable, bool inOrder, const uns
     
     
     kNet::NetworkServer* server = network_->GetServer();
     kNet::NetworkServer* server = network_->GetServer();
     if (server)
     if (server)
-        server->BroadcastMessage(msgID, reliable, inOrder, priority, contentID, (const char*)data, numBytes);
+        server->BroadcastMessage(msgID, reliable, inOrder, 0, contentID, (const char*)data, numBytes);
     else
     else
         LOGERROR("Server not running, can not broadcast messages");
         LOGERROR("Server not running, can not broadcast messages");
 }
 }
@@ -489,7 +488,7 @@ void Network::OnServerConnected()
     // Send the identity map now
     // Send the identity map now
     VectorBuffer msg;
     VectorBuffer msg;
     msg.WriteVariantMap(serverConnection_->GetIdentity());
     msg.WriteVariantMap(serverConnection_->GetIdentity());
-    serverConnection_->SendMessage(MSG_IDENTITY, true, true, msg, NET_HIGH_PRIORITY);
+    serverConnection_->SendMessage(MSG_IDENTITY, true, true, msg);
     
     
     SendEvent(E_SERVERCONNECTED);
     SendEvent(E_SERVERCONNECTED);
 }
 }

+ 2 - 2
Engine/Network/Network.h

@@ -69,9 +69,9 @@ public:
     /// Stop the server.
     /// Stop the server.
     void StopServer();
     void StopServer();
     /// Broadcast a message with content ID to all client connections.
     /// Broadcast a message with content ID to all client connections.
-    void BroadcastMessage(int msgID, bool reliable, bool inOrder, const VectorBuffer& msg, unsigned priority = 0, unsigned contentID = 0);
+    void BroadcastMessage(int msgID, bool reliable, bool inOrder, const VectorBuffer& msg, unsigned contentID = 0);
     /// Broadcast a message with content ID to all client connections.
     /// Broadcast a message with content ID to all client connections.
-    void BroadcastMessage(int msgID, bool reliable, bool inOrder, const unsigned char* data, unsigned numBytes, unsigned priority = 0, unsigned contentID = 0);
+    void BroadcastMessage(int msgID, bool reliable, bool inOrder, const unsigned char* data, unsigned numBytes, unsigned contentID = 0);
     /// Broadcast a remote event to all client connections.
     /// Broadcast a remote event to all client connections.
     void BroadcastRemoteEvent(StringHash eventType, bool inOrder, const VariantMap& eventData = VariantMap());
     void BroadcastRemoteEvent(StringHash eventType, bool inOrder, const VariantMap& eventData = VariantMap());
     /// Broadcast a remote event to all client connections in a specific scene.
     /// Broadcast a remote event to all client connections in a specific scene.

+ 0 - 4
Engine/Network/Protocol.h

@@ -64,7 +64,3 @@ static const int MSG_REMOTENODEEVENT = 0x15;
 static const unsigned CONTROLS_CONTENT_ID = 1;
 static const unsigned CONTROLS_CONTENT_ID = 1;
 /// Package file fragment size.
 /// Package file fragment size.
 static const unsigned PACKAGE_FRAGMENT_SIZE = 1024;
 static const unsigned PACKAGE_FRAGMENT_SIZE = 1024;
-/// Message high priority.
-static const unsigned NET_HIGH_PRIORITY = 100;
-/// Message low priority (default.)
-static const unsigned NET_LOW_PRIORITY = 0;

+ 6 - 3
ThirdParty/kNet/CMakeLists.txt

@@ -59,6 +59,9 @@ AddCompilationDefine(KNET_THREAD_CHECKING_ENABLED)
 # Enable storing profiling data from different network level events.
 # Enable storing profiling data from different network level events.
 #AddCompilationDefine(KNET_NETWORK_PROFILING)
 #AddCompilationDefine(KNET_NETWORK_PROFILING)
 
 
+# Urho3D does not need message priorities. Disable MaxHeap for improved performance.
+AddCompilationDefine(KNET_NO_MAXHEAP)
+
 if (USE_BOOST)
 if (USE_BOOST)
    AddCompilationDefine(KNET_USE_BOOST)
    AddCompilationDefine(KNET_USE_BOOST)
 
 
@@ -157,14 +160,14 @@ elseif (UNIX)
 endif()
 endif()
 
 
 #AddCompilationUnitNameDefines(kNetSourceFiles)
 #AddCompilationUnitNameDefines(kNetSourceFiles)
-#TODO: To clean up, move the lines of code below into a macro, like shown above. Disabled for now since passing a list to a CMake macro was problematic.
-# Urho3D: use only on Windows
+#TODO: To clean up, move the lines of code below into a macro, like shown above. Disabled for now since passing a list to a CMake macro was problematic.
+# Urho3D: use only on Windows
 if (WIN32)
 if (WIN32)
    foreach(srcFile ${kNetSourceFiles})
    foreach(srcFile ${kNetSourceFiles})
       get_filename_component(baseName ${srcFile} NAME)
       get_filename_component(baseName ${srcFile} NAME)
       set_source_files_properties(${srcFile} PROPERTIES COMPILE_FLAGS "-DDEBUG_CPP_NAME=\"\\\"${baseName}\"\\\"")
       set_source_files_properties(${srcFile} PROPERTIES COMPILE_FLAGS "-DDEBUG_CPP_NAME=\"\\\"${baseName}\"\\\"")
    endforeach()
    endforeach()
-endif()
+endif()
 
 
 add_library(kNet STATIC ${kNetSourceFiles} ${kNetHeaderFiles})
 add_library(kNet STATIC ${kNetSourceFiles} ${kNetHeaderFiles})