Various improvements to the networking
This commit is contained in:
@@ -21,7 +21,7 @@ ENetPacketFlag ChannelTypeToPacketFlag(const NetworkChannelType channel)
|
||||
int flag = 0; // Maybe use ENET_PACKET_FLAG_NO_ALLOCATE?
|
||||
|
||||
// Add reliable flag when it is "reliable" channel
|
||||
if (channel > NetworkChannelType::UnreliableOrdered)
|
||||
if (channel == NetworkChannelType::Reliable || channel == NetworkChannelType::ReliableOrdered)
|
||||
flag |= ENET_PACKET_FLAG_RELIABLE;
|
||||
|
||||
// Use unsequenced flag when the flag is unreliable. We have to sequence all other packets.
|
||||
|
||||
@@ -15,26 +15,22 @@ API_ENUM(Namespace="FlaxEngine.Networking") enum class NetworkChannelType
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Unreliable channel type.
|
||||
/// Messages can be lost or arrive out-of-order.
|
||||
/// Unreliable channel type. Messages can be lost or arrive out-of-order.
|
||||
/// </summary>
|
||||
Unreliable,
|
||||
|
||||
/// <summary>
|
||||
/// Unreliable-ordered channel type.
|
||||
/// Messages can be lost but always arrive in order.
|
||||
/// Unreliable-ordered channel type. Messages can be lost but always arrive in order.
|
||||
/// </summary>
|
||||
UnreliableOrdered,
|
||||
|
||||
/// <summary>
|
||||
/// Reliable channel type.
|
||||
/// Messages won't be lost but may arrive out-of-order.
|
||||
/// Reliable channel type. Messages won't be lost but may arrive out-of-order.
|
||||
/// </summary>
|
||||
Reliable,
|
||||
|
||||
/// <summary>
|
||||
/// Reliable-ordered channel type.
|
||||
/// Messages won't be lost and always arrive in order.
|
||||
/// Reliable-ordered channel type. Messages won't be lost and always arrive in order.
|
||||
/// </summary>
|
||||
ReliableOrdered
|
||||
ReliableOrdered,
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ FORCE_INLINE void NetworkRpcInitArg(Array<void*, FixedAllocation<16>>& args, con
|
||||
|
||||
// Gets the pointers to the RPC arguments into the args buffer
|
||||
template<typename T, typename... Params>
|
||||
FORCE_INLINE void NetworkRpcInitArg(Array<void*, FixedAllocation<16>>& args, const T& first, Params&... params)
|
||||
FORCE_INLINE void NetworkRpcInitArg(Array<void*, FixedAllocation<16>>& args, const T& first, Params&&... params)
|
||||
{
|
||||
NetworkRpcInitArg(args, first);
|
||||
NetworkRpcInitArg(args, Forward<Params>(params)...);
|
||||
@@ -50,9 +50,10 @@ FORCE_INLINE void NetworkRpcInitArg(Array<void*, FixedAllocation<16>>& args, con
|
||||
const NetworkRpcInfo* rpcInfoPtr = NetworkRpcInfo::RPCsTable.TryGet(NetworkRpcName(type::TypeInitializer, StringAnsiView(#name))); \
|
||||
if (rpcInfoPtr == nullptr) \
|
||||
{ \
|
||||
LOG(Error, "Invalid RPC {0}::{1}. Ensure to use proper type name and method name (and 'Network' tag on a code module).", TEXT(#type), TEXT(#name)); \
|
||||
if (Platform::IsDebuggerPresent()) \
|
||||
PLATFORM_DEBUG_BREAK; \
|
||||
Platform::Assert("Invalid RPC. Ensure to use proper type name and method name.", __FILE__, __LINE__); \
|
||||
Platform::Assert("Invalid RPC.", __FILE__, __LINE__); \
|
||||
return; \
|
||||
} \
|
||||
const NetworkRpcInfo& rpcInfo = *rpcInfoPtr; \
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace Flax.Build.Bindings
|
||||
public static event Action<BuildData, IGrouping<string, Module>, StringBuilder> GenerateCppBinaryModuleHeader;
|
||||
public static event Action<BuildData, IGrouping<string, Module>, StringBuilder> GenerateCppBinaryModuleSource;
|
||||
public static event Action<BuildData, ModuleInfo, StringBuilder> GenerateCppModuleSource;
|
||||
public static event Action<BuildData, ApiTypeInfo, StringBuilder> GenerateCppTypeInternalsStatics;
|
||||
public static event Action<BuildData, ApiTypeInfo, StringBuilder> GenerateCppTypeInternals;
|
||||
public static event Action<BuildData, ApiTypeInfo, StringBuilder> GenerateCppTypeInitRuntime;
|
||||
public static event Action<BuildData, VirtualClassInfo, FunctionInfo, int, int, StringBuilder> GenerateCppScriptWrapperFunction;
|
||||
@@ -1553,6 +1554,7 @@ namespace Flax.Build.Bindings
|
||||
|
||||
if (classInfo.IsAutoSerialization)
|
||||
GenerateCppAutoSerialization(buildData, contents, moduleInfo, classInfo, classTypeNameNative);
|
||||
GenerateCppTypeInternalsStatics?.Invoke(buildData, classInfo, contents);
|
||||
|
||||
contents.AppendLine();
|
||||
contents.AppendFormat("class {0}Internal", classTypeNameInternal).AppendLine();
|
||||
@@ -1868,6 +1870,7 @@ namespace Flax.Build.Bindings
|
||||
|
||||
if (structureInfo.IsAutoSerialization)
|
||||
GenerateCppAutoSerialization(buildData, contents, moduleInfo, structureInfo, structureTypeNameNative);
|
||||
GenerateCppTypeInternalsStatics?.Invoke(buildData, structureInfo, contents);
|
||||
|
||||
contents.AppendLine();
|
||||
contents.AppendFormat("class {0}Internal", structureTypeNameInternal).AppendLine();
|
||||
@@ -2097,6 +2100,8 @@ namespace Flax.Build.Bindings
|
||||
var interfaceTypeNameManaged = interfaceInfo.FullNameManaged;
|
||||
var interfaceTypeNameInternal = interfaceInfo.FullNameNativeInternal;
|
||||
|
||||
GenerateCppTypeInternalsStatics?.Invoke(buildData, interfaceInfo, contents);
|
||||
|
||||
// Wrapper interface implement to invoke scripting if inherited in C# or VS
|
||||
contents.AppendLine();
|
||||
contents.AppendFormat("class {0}Wrapper : public ", interfaceTypeNameInternal).Append(interfaceTypeNameNative).AppendLine();
|
||||
|
||||
@@ -90,13 +90,13 @@ namespace Flax.Build.Plugins
|
||||
|
||||
private void OnParseMemberTag(ref bool valid, BindingsGenerator.TagParameter tag, MemberInfo memberInfo)
|
||||
{
|
||||
if (tag.Tag == NetworkReplicated)
|
||||
if (string.Equals(tag.Tag, NetworkReplicated, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Mark member as replicated
|
||||
valid = true;
|
||||
memberInfo.SetTag(NetworkReplicated, string.Empty);
|
||||
}
|
||||
else if (tag.Tag == NetworkRpc)
|
||||
else if (string.Equals(tag.Tag, NetworkRpc, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Mark member as rpc
|
||||
valid = true;
|
||||
@@ -466,6 +466,10 @@ namespace Flax.Build.Plugins
|
||||
|
||||
private void OnBuildDotNetAssembly(TaskGraph graph, Builder.BuildData buildData, NativeCpp.BuildOptions buildOptions, Task buildTask, IGrouping<string, Module> binaryModule)
|
||||
{
|
||||
// Skip FlaxEngine.dll
|
||||
if (string.Equals(binaryModule.Key, "FlaxEngine", StringComparison.Ordinal))
|
||||
return;
|
||||
|
||||
// Skip assemblies not using netowrking
|
||||
if (!binaryModule.Any(module => module.Tags.ContainsKey(Network)))
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user