net.AllowReliableMulticastToNonRelevantChannels
net.AllowReliableMulticastToNonRelevantChannels
#Overview
name: net.AllowReliableMulticastToNonRelevantChannels
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allow Reliable Server Multicasts to be sent to non-Relevant Actors, as long as their is an existing ActorChannel.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of net.AllowReliableMulticastToNonRelevantChannels is to control whether reliable server multicasts can be sent to non-relevant actors in the networking system of Unreal Engine 5. This setting is primarily used in the networking and replication subsystem of the engine.
The Unreal Engine networking system relies on this setting variable, particularly within the NetDriver module. It’s used to determine the behavior of reliable multicast remote procedure calls (RPCs) for actors that are not currently considered relevant to a client.
The value of this variable is set as a console variable with a default value of 1 (enabled). It can be modified at runtime through the console or configuration files.
This variable interacts closely with the networking relevancy system and the reliable RPC system. It’s associated with the C++ variable CVarAllowReliableMulticastToNonRelevantChannels, which is used to access its value in the code.
Developers must be aware that enabling this setting (which is the default) allows reliable multicast RPCs to be sent to non-relevant actors, as long as there is an existing ActorChannel. This can increase network traffic but ensures that important reliable messages are not lost.
Best practices when using this variable include:
- Consider the performance implications of enabling this feature, especially in games with many actors or frequent multicasts.
- Use it in conjunction with proper actor relevancy settings to optimize network traffic.
- Monitor network performance and adjust this setting if necessary.
Regarding the associated variable CVarAllowReliableMulticastToNonRelevantChannels:
Its purpose is to provide programmatic access to the net.AllowReliableMulticastToNonRelevantChannels console variable within the C++ code.
This variable is used in the NetDriver module, specifically in the process of sending remote function calls (RPCs).
The value of this variable is set when the console variable is initialized, and it reflects the current state of the net.AllowReliableMulticastToNonRelevantChannels setting.
It interacts directly with the networking code that determines whether to send reliable multicast RPCs to non-relevant actors.
Developers should be aware that this variable is accessed using the GetValueOnGameThread() method, which suggests it should only be read from the game thread for thread-safety reasons.
Best practices for using this variable include:
- Access it only from the game thread.
- Use it as a condition in networking code to determine whether to send certain types of RPCs.
- Consider caching its value if it’s accessed frequently, to avoid repeated calls to GetValueOnGameThread().
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetDriver.cpp:408
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarAllowReliableMulticastToNonRelevantChannels(
TEXT("net.AllowReliableMulticastToNonRelevantChannels"),
1,
TEXT("Allow Reliable Server Multicasts to be sent to non-Relevant Actors, as long as their is an existing ActorChannel."));
static int32 GNetControlChannelDestructionInfo = 0;
static FAutoConsoleVariableRef CVarNetControlChannelDestructionInfo(
TEXT("net.ControlChannelDestructionInfo"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarAllowReliableMulticastToNonRelevantChannels
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetDriver.cpp:407
Scope: file
Source code excerpt:
TEXT("If nonzero, actor channels will be pooled to save memory and object creation cost."));
static TAutoConsoleVariable<int32> CVarAllowReliableMulticastToNonRelevantChannels(
TEXT("net.AllowReliableMulticastToNonRelevantChannels"),
1,
TEXT("Allow Reliable Server Multicasts to be sent to non-Relevant Actors, as long as their is an existing ActorChannel."));
static int32 GNetControlChannelDestructionInfo = 0;
static FAutoConsoleVariableRef CVarNetControlChannelDestructionInfo(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/NetDriver.cpp:7529
Scope: file
Source code excerpt:
// don't want to lose Reliable RPCs.
if (Actor->IsNetRelevantFor(Viewer.InViewer, Viewer.ViewTarget, Viewer.ViewLocation) ||
((Function->FunctionFlags & FUNC_NetReliable) && !!CVarAllowReliableMulticastToNonRelevantChannels.GetValueOnGameThread() && Connection->FindActorChannelRef(Actor)))
{
// We don't want to call this unless necessary, and it will internally handle being called multiple times before a clear
// Builds any shared serialization state for this rpc
RepLayout->BuildSharedSerializationForRPC(Parameters);
InternalProcessRemoteFunctionPrivate(Actor, SubObject, Connection, Function, Parameters, OutParms, Stack, bIsServer, RemoteFunctionFlags);