UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DataBunch.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 DataBunch.h: Unreal bunch class.
5=============================================================================*/
6#pragma once
7
8#include "CoreMinimal.h"
9#include "Misc/NetworkGuid.h"
10#include "UObject/CoreNet.h"
11#include "EngineLogs.h"
14
15class UChannel;
16class UNetConnection;
17
18extern const int32 MAX_BUNCH_SIZE;
19
20//
21// A bunch of data to send.
22//
24{
25public:
26 // Variables.
29 double Time;
37 UE_DEPRECATED(5.3, "Replication pausing is deprecated")
38 uint8 bIsReplicationPaused:1; // Replication on this channel is being paused by the server
40 uint8 bPartial:1; // Not a complete bunch
41 uint8 bPartialInitial:1; // The first bunch of a partial bunch
42 uint8 bPartialFinal:1; // The final bunch of a partial bunch
43 uint8 bHasPackageMapExports:1; // This bunch has networkGUID name/id pairs
44 uint8 bHasMustBeMappedGUIDs:1; // This bunch has guids that must be mapped before we can process this bunch
45 uint8 bPartialCustomExportsFinal:1; // This bunch marks the end of the CustomExports data that needs to be processed immediately (not queued)
46 uint8 bOutWantsFullInitState:1; // Set this true to force all replicated properties to be serialized in the initial bunch even if they do not differ from Archetype baseline
47
49
50 TArray< FNetworkGUID > ExportNetGUIDs; // List of GUIDs that went out on this bunch
52 TArray<UE::Net::FNetToken, TInlineAllocator<4>> NetTokensPendingExport; // List of NetTokens that will be exported if needed with this bunch.
53
54#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
55 FString DebugString;
57 {
59 }
60 FString GetDebugString() const
61 {
62 return DebugString;
63 }
64#else
65 inline void SetDebugString(FString DebugStr)
66 {
67
68 }
69 inline FString GetDebugString() const
70 {
71 return FString();
72 }
73#endif
74
75 // Functions.
80
82 FOutBunch(FOutBunch&&) = default;
83 FOutBunch(const FOutBunch&) = default;
85 FOutBunch& operator=(const FOutBunch&) = default;
87
88 virtual ~FOutBunch();
89
90 FString ToString()
91 {
92 // String cating like this is super slow! Only enable in non shipping builds
93#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
94 FString Str(TEXT("FOutBunch: "));
95 Str += FString::Printf(TEXT("Channel[%d] "), ChIndex);
96 Str += FString::Printf(TEXT("ChSequence: %d "), ChSequence);
97 Str += FString::Printf(TEXT("NumBits: %lld "), GetNumBits());
98 Str += FString::Printf(TEXT("PacketId: %d "), PacketId);
99 Str += FString::Printf(TEXT("bOpen: %d "), bOpen);
100 Str += FString::Printf(TEXT("bClose: %d "), bClose);
101 if (bClose)
102 {
103 Str += FString::Printf(TEXT("CloseReason: %s "), LexToString(CloseReason));
104 }
106 Str += FString::Printf(TEXT("bIsReplicationPaused: %d "), bIsReplicationPaused);
108 Str += FString::Printf(TEXT("bReliable: %d "), bReliable);
109 Str += FString::Printf(TEXT("bPartial: %d//%d//%d "), bPartial, bPartialInitial, bPartialFinal);
110 Str += FString::Printf(TEXT("bHasPackageMapExports: %d "), bHasPackageMapExports);
111 Str += FString::Printf(TEXT("NetTokensPendingExport: %d "), NetTokensPendingExport.Num());
112 Str += GetDebugString();
113#else
114 FString Str = FString::Printf(TEXT("Channel[%d]. Seq %d. PacketId: %d"), ChIndex, ChSequence, PacketId);
115#endif
116 return Str;
117 }
118
119 ENGINE_API virtual void CountMemory(FArchive& Ar) const override;
120 ENGINE_API virtual void Reset() override;
121};
122
123//
124// A bunch of data received from a channel.
125//
127{
128public:
129 // Variables.
130 int32 PacketId; // Note this must stay as first member variable in FInBunch for FInBunch(FInBunch, bool) to work
138 UE_DEPRECATED(5.3, "Replication pausing is deprecated")
139 uint8 bIsReplicationPaused:1; // Replication on this channel is being paused by the server
141 uint8 bPartial:1; // Not a complete bunch
142 uint8 bPartialInitial:1; // The first bunch of a partial bunch
143 uint8 bPartialFinal:1; // The final bunch of a partial bunch
144 uint8 bHasPackageMapExports:1; // This bunch has networkGUID name/id pairs
145 uint8 bHasMustBeMappedGUIDs:1; // This bunch has guids that must be mapped before we can process this bunch
146 uint8 bPartialCustomExportsFinal:1; // This bunch marks the end of the extensions data that needs to be processed immediately (not queued)
148
150
151 FString ToString()
152 {
153 // String cating like this is super slow! Only enable in non shipping builds
154#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
155 FString Str(TEXT("FInBunch: "));
156 Str += FString::Printf(TEXT("Channel[%d] "), ChIndex);
157 Str += FString::Printf(TEXT("ChSequence: %d "), ChSequence);
158 Str += FString::Printf(TEXT("NumBits: %lld "), GetNumBits());
159 Str += FString::Printf(TEXT("PacketId: %d "), PacketId);
160 Str += FString::Printf(TEXT("bOpen: %d "), bOpen);
161 Str += FString::Printf(TEXT("bClose: %d "), bClose);
162 if (bClose)
163 {
164 Str += FString::Printf(TEXT("CloseReason: %s "), LexToString(CloseReason));
165 }
167 Str += FString::Printf(TEXT("bIsReplicationPaused: %d "), bIsReplicationPaused);
169 Str += FString::Printf(TEXT("bReliable: %d "), bReliable);
170 Str += FString::Printf(TEXT("bPartial: %d//%d//%d "), bPartial, bPartialInitial, bPartialFinal);
171 Str += FString::Printf(TEXT("bHasPackageMapExports: %d "), bHasPackageMapExports );
172 Str += FString::Printf(TEXT("bHasMustBeMappedGUIDs: %d "), bHasMustBeMappedGUIDs );
173 Str += FString::Printf(TEXT("bPartialCustomExportsFinal: %d "), bPartialCustomExportsFinal);
174 Str += FString::Printf(TEXT("bIgnoreRPCs: %d "), bIgnoreRPCs );
175#else
176 FString Str = FString::Printf(TEXT("Channel[%d]. Seq %d. PacketId: %d"), ChIndex, ChSequence, PacketId);
177#endif
178 return Str;
179 }
180
181 // Functions.
183 ENGINE_API FInBunch( FInBunch &InBunch, bool CopyBuffer );
184
186 FInBunch(FInBunch&&) = default;
187 FInBunch(const FInBunch&) = default;
189 FInBunch& operator=(const FInBunch&) = default;
191
192 virtual void CountMemory(FArchive& Ar) const override;
193
194 virtual uint32 EngineNetVer() const override;
195 virtual uint32 GameNetVer() const override;
196 virtual void SetEngineNetVer(const uint32 InEngineNetVer) override;
197 virtual void SetGameNetVer(const uint32 InGameNetVer) override;
198};
199
202{
204
206 {
207 UE_LOG(LogNet, Fatal,TEXT("Cannot send Names on the control channel"));
208 SetError();
209 return *this;
210 }
212 {
213 UE_LOG(LogNet, Fatal,TEXT("Cannot send Objects on the control channel"));
214 SetError();
215 return *this;
216 }
217};
218
219
#define NULL
Definition oodle2base.h:134
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
EChannelCloseReason
Definition CoreNetTypes.h:49
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const int32 MAX_BUNCH_SIZE
Definition DataBunch.cpp:13
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
const TCHAR * LexToString(EAnalyticsRecordEventMode Mode)
Definition IAnalyticsProvider.cpp:5
#define UE_LOG(CategoryName, Verbosity, Format,...)
Definition LogMacros.h:270
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
CORE_API void SetError()
Definition Archive.cpp:314
Definition DataBunch.h:127
uint8 bReliable
Definition DataBunch.h:140
FName ChName
Definition DataBunch.h:134
int32 PacketId
Definition DataBunch.h:130
int32 ChSequence
Definition DataBunch.h:135
uint8 bClose
Definition DataBunch.h:137
uint8 bHasPackageMapExports
Definition DataBunch.h:144
ENGINE_API virtual PRAGMA_ENABLE_DEPRECATION_WARNINGS void CountMemory(FArchive &Ar) const override
Definition DataBunch.cpp:78
uint8 bPartial
Definition DataBunch.h:141
FInBunch * Next
Definition DataBunch.h:131
int32 ChIndex
Definition DataBunch.h:133
virtual void SetEngineNetVer(const uint32 InEngineNetVer) override
Definition DataBunch.cpp:98
virtual uint32 GameNetVer() const override
Definition DataBunch.cpp:93
PRAGMA_DISABLE_DEPRECATION_WARNINGS FInBunch(FInBunch &&)=default
FInBunch & operator=(FInBunch &&)=default
uint8 bOpen
Definition DataBunch.h:136
uint8 bPartialCustomExportsFinal
Definition DataBunch.h:146
FString ToString()
Definition DataBunch.h:151
virtual void SetGameNetVer(const uint32 InGameNetVer) override
Definition DataBunch.cpp:103
uint8 bPartialFinal
Definition DataBunch.h:143
uint8 bIsReplicationPaused
Definition DataBunch.h:139
EChannelCloseReason CloseReason
Definition DataBunch.h:149
UNetConnection * Connection
Definition DataBunch.h:132
virtual uint32 EngineNetVer() const override
Definition DataBunch.cpp:88
uint8 bPartialInitial
Definition DataBunch.h:142
FInBunch(const FInBunch &)=default
FInBunch & operator=(const FInBunch &)=default
uint8 bHasMustBeMappedGUIDs
Definition DataBunch.h:145
uint8 bIgnoreRPCs
Definition DataBunch.h:147
Definition NameTypes.h:617
Definition CoreNet.h:415
Definition CoreNet.h:384
class UPackageMap * PackageMap
Definition CoreNet.h:390
Definition NetworkGuid.h:12
Definition DataBunch.h:24
double Time
Definition DataBunch.h:29
void SetDebugString(FString DebugStr)
Definition DataBunch.h:56
UChannel * Channel
Definition DataBunch.h:28
uint8 bOutWantsFullInitState
Definition DataBunch.h:46
uint8 bPartial
Definition DataBunch.h:40
ENGINE_API FOutBunch()
Definition DataBunch.cpp:116
FString GetDebugString() const
Definition DataBunch.h:60
PRAGMA_DISABLE_DEPRECATION_WARNINGS FOutBunch(FOutBunch &&)=default
uint8 bPartialCustomExportsFinal
Definition DataBunch.h:45
int32 ChSequence
Definition DataBunch.h:32
virtual ENGINE_API void Reset() override
Definition DataBunch.cpp:188
FOutBunch(const FOutBunch &)=default
EChannelCloseReason CloseReason
Definition DataBunch.h:48
uint8 bOpen
Definition DataBunch.h:35
FOutBunch & operator=(FOutBunch &&)=default
TArray< uint64 > NetFieldExports
Definition DataBunch.h:51
FOutBunch & operator=(const FOutBunch &)=default
FString DebugString
Definition DataBunch.h:55
uint8 bClose
Definition DataBunch.h:36
int32 ChIndex
Definition DataBunch.h:30
uint8 bPartialInitial
Definition DataBunch.h:41
uint8 bHasMustBeMappedGUIDs
Definition DataBunch.h:44
uint8 bIsReplicationPaused
Definition DataBunch.h:38
int32 PacketId
Definition DataBunch.h:33
TArray< FNetworkGUID > ExportNetGUIDs
Definition DataBunch.h:50
uint8 bHasPackageMapExports
Definition DataBunch.h:43
virtual ENGINE_API void CountMemory(FArchive &Ar) const override
Definition DataBunch.cpp:194
uint8 ReceivedAck
Definition DataBunch.h:34
uint8 bPartialFinal
Definition DataBunch.h:42
FOutBunch * Next
Definition DataBunch.h:27
ENGINE_API virtual PRAGMA_ENABLE_DEPRECATION_WARNINGS ~FOutBunch()
Definition DataBunch.cpp:204
uint8 bReliable
Definition DataBunch.h:39
FName ChName
Definition DataBunch.h:31
TArray< UE::Net::FNetToken, TInlineAllocator< 4 > > NetTokensPendingExport
Definition DataBunch.h:52
FString ToString()
Definition DataBunch.h:90
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
Definition ContainerAllocationPolicies.h:894
Definition Channel.h:63
Definition NetConnection.h:284
Definition Object.h:95
Definition CoreNet.h:191
Definition AdvancedWidgetsModule.cpp:13
UE_FORCEINLINE_HINT int64 GetNumBits() const
Definition BitReader.h:185
UE_FORCEINLINE_HINT int64 GetNumBits(void) const
Definition BitWriter.h:121
Definition DataBunch.h:202
FArchive & operator<<(UObject *&Object)
Definition DataBunch.h:211
FArchive & operator<<(FName &Name)
Definition DataBunch.h:205