Browse Source

Add MSG_USER const. Fix https://github.com/urho3d/Urho3D/issues/2734 (#2735)

1vanK 5 years ago
parent
commit
107d99711e

+ 2 - 1
Source/Samples/16_Chat/Chat.cpp

@@ -32,6 +32,7 @@
 #include <Urho3D/IO/VectorBuffer.h>
 #include <Urho3D/Network/Network.h>
 #include <Urho3D/Network/NetworkEvents.h>
+#include <Urho3D/Network/Protocol.h>
 #include <Urho3D/Resource/ResourceCache.h>
 #include <Urho3D/Scene/Scene.h>
 #include <Urho3D/UI/Button.h>
@@ -51,7 +52,7 @@
 #endif
 
 // Identifier for the chat network messages
-const int MSG_CHAT = 154;
+const int MSG_CHAT = MSG_USER + 0;
 // UDP port we will use
 const unsigned short CHAT_SERVER_PORT = 2345;
 

+ 4 - 0
Source/Urho3D/AngelScript/Generated_GlobalVariables.cpp

@@ -508,6 +508,10 @@ void ASRegisterGenerated_GlobalVariables(asIScriptEngine* engine)
     // static const int MSG_PACKED_MESSAGE | File: ../Network/Protocol.h
     engine->RegisterGlobalProperty("const int MSG_PACKED_MESSAGE", (void*)&MSG_PACKED_MESSAGE);
 #endif
+#ifdef URHO3D_NETWORK
+    // static const int MSG_USER | File: ../Network/Protocol.h
+    engine->RegisterGlobalProperty("const int MSG_USER", (void*)&MSG_USER);
+#endif
 #ifdef URHO3D_NETWORK
     // static const unsigned CONTROLS_CONTENT_ID | File: ../Network/Protocol.h
     engine->RegisterGlobalProperty("const uint CONTROLS_CONTENT_ID", (void*)&CONTROLS_CONTENT_ID);

+ 3 - 0
Source/Urho3D/LuaScript/pkgs/Network/Protocol.pkg

@@ -0,0 +1,3 @@
+$#include "Network/Protocol.h"
+
+static const int MSG_USER;

+ 1 - 0
Source/Urho3D/LuaScript/pkgs/NetworkLuaAPI.pkg

@@ -2,6 +2,7 @@ $pfile "Network/Connection.pkg"
 $pfile "Network/HttpRequest.pkg"
 $pfile "Network/Network.pkg"
 $pfile "Network/NetworkPriority.pkg"
+$pfile "Network/Protocol.pkg"
 
 $using namespace Urho3D;
 $#pragma warning(disable:4800)

+ 3 - 0
Source/Urho3D/Network/Protocol.h

@@ -67,6 +67,9 @@ static const int MSG_PACKAGEINFO = 0x98;
 /// Packet that includes all the above messages
 static const int MSG_PACKED_MESSAGE = 0x99;
 
+/// Used to define custom messages, usually of the form MSG_USER + x, where x is an integer value.
+static const int MSG_USER = 0x200;
+
 /// Fixed content ID for client controls update.
 static const unsigned CONTROLS_CONTENT_ID = 1;
 /// Package file fragment size.

+ 1 - 1
bin/Data/LuaScripts/16_Chat.lua

@@ -6,7 +6,7 @@
 require "LuaScripts/Utilities/Sample"
 
 -- Identifier for the chat network messages
-local MSG_CHAT = 153
+local MSG_CHAT = MSG_USER + 0
 -- UDP port we will use
 local CHAT_SERVER_PORT = 2345
 

+ 1 - 1
bin/Data/Scripts/16_Chat.as

@@ -6,7 +6,7 @@
 #include "Scripts/Utilities/Sample.as"
 
 // Identifier for the chat network messages
-const int MSG_CHAT = 153;
+const int MSG_CHAT = MSG_USER + 0;
 // UDP port we will use
 const uint CHAT_SERVER_PORT = 2345;