UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Channel.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "UObject/Object.h"
8#include "UObject/CoreNet.h"
10#include "Channel.generated.h"
11
13
14class FInBunch;
15class FOutBunch;
16class UNetConnection;
17
18// Constant for all buffers that are reading from the network
20
25{
26 CHTYPE_None = 0, // Invalid type.
27 CHTYPE_Control = 1, // Connection control.
28 CHTYPE_Actor = 2, // Actor-update channel.
29
30 // @todo: Remove and reassign number to CHTYPE_Voice (breaks net compatibility)
31 CHTYPE_File = 3, // Binary file transfer.
32
33 CHTYPE_Voice = 4, // VoIP data channel
34 CHTYPE_MAX = 8, // Maximum.
35};
36
41{
42 None = (1 << 0),
43 OpenedLocally = (1 << 1)
44};
46
53
54// The channel index to use for voice
55#define VOICE_CHANNEL_INDEX 1
56
57
61UCLASS(abstract, transient, MinimalAPI)
63{
65
66public:
67 UPROPERTY()
68 TObjectPtr<class UNetConnection> Connection; // Owner connection.
69
70 // Variables.
71 uint32 OpenAcked:1; // If OpenedLocally is true, this means we have acknowledged the packet we sent the bOpen bunch on. Otherwise, it means we have received the bOpen bunch from the server.
72 uint32 Closing:1; // State of the channel.
73 uint32 Dormant:1; // Channel is going dormant (it will close but the client will not destroy
74 UE_DEPRECATED(5.3, "Replication pausing is deprecated and will be removed")
75 uint32 bIsReplicationPaused:1; // Replication is being paused, but channel will not be closed
76 uint32 OpenTemporary:1; // Opened temporarily.
77 uint32 Broken:1; // Has encountered errors and is ignoring subsequent packets.
78 uint32 bTornOff:1; // Actor associated with this channel was torn off
79 uint32 bPendingDormancy:1; // Channel wants to go dormant (it will check during tick if it can go dormant)
80 uint32 bIsInDormancyHysteresis:1; // Channel wants to go dormant, and is otherwise ready to become dormant, but is waiting for a timeout before doing so.
81 uint32 bPausedUntilReliableACK:1; // Unreliable property replication is paused until all reliables are ack'd.
82 uint32 SentClosingBunch:1; // Set when sending closing bunch to avoid recursion in send-failure-close case.
83 uint32 bPooled:1; // Set when placed in the actor channel pool
84 uint32 OpenedLocally:1; // Whether channel was opened locally or by remote.
85 uint32 bOpenedForCheckpoint:1; // Whether channel was opened by replay checkpoint recording
86 int32 ChIndex; // Index of this channel.
87 FPacketIdRange OpenPacketId; // If OpenedLocally is true, this is the packet we sent the bOpen bunch on. Otherwise, it's the packet we received the bOpen bunch on.
88 FName ChName; // Name of the type of this channel.
89 int32 NumInRec; // Number of packets in InRec.
90 int32 NumOutRec; // Number of packets in OutRec.
91 class FInBunch* InRec; // Incoming data with queued dependencies.
92 class FOutBunch* OutRec; // Outgoing reliable unacked data.
93 class FInBunch* InPartialBunch; // Partial bunch we are receiving (incoming partial bunches are appended to this)
94
95 // UObject overrides
96
99
103
105 virtual void ReInit() {}
106
108 ENGINE_API virtual void SetClosingFlag();
109
112
114 ENGINE_API virtual FString Describe();
115
117 virtual void ReceivedBunch( FInBunch& Bunch ) PURE_VIRTUAL(UChannel::ReceivedBunch,);
118
121
123 ENGINE_API virtual void ReceivedNak( int32 NakPacketId );
124
126 ENGINE_API virtual void Tick();
127
129 virtual bool CanStopTicking() const { return !bPendingDormancy; }
130
131 // General channel functions.
134
136 ENGINE_API void ReceivedAcks();
137
139 ENGINE_API bool ReceivedSequencedBunch( FInBunch& Bunch );
140
145 ENGINE_API void ReceivedRawBunch( FInBunch & Bunch, bool & bOutSkipAck );
146
148 UE_DEPRECATED(5.5, "Use GetAdditionalRequiredBunches")
149 ENGINE_API virtual void AppendExportBunches(TArray< FOutBunch* >& OutExportBunches);
150
153
155 ENGINE_API virtual void AppendMustBeMappedGuids( FOutBunch* Bunch );
156
159
161 UE_DEPRECATED(5.6, "Replaced with a version that doesn't have a saturate option.")
163
165 ENGINE_API bool IsNetReady() const;
166
168 ENGINE_API void AssertInSequenced();
169
171 ENGINE_API void ConditionalCleanUp(const bool bForDestroy, EChannelCloseReason CloseReason);
172
174 virtual bool ReadyForDormancy(bool suppressLogs=false) { return false; }
175
177 virtual void StartBecomingDormant() { }
178
179 UE_DEPRECATED(5.3, "Will be removed from test/shipping in the future.")
180 ENGINE_API void PrintReliableBunchBuffer();
181
182 /* Notification that this channel has been placed in a channel pool and needs to reset to its original state so it can be used again like a new channel */
183 ENGINE_API virtual void AddedToChannelPool();
184
186 ENGINE_API virtual bool HasAcknowledgedAllReliableData() const;
187
189
191 virtual void BecomeDormant() { }
192
194 ENGINE_API virtual bool CleanUp( const bool bForDestroy, EChannelCloseReason CloseReason );
195
197 UE_DEPRECATED(5.3, "Replication pausing is deprecated and will be removed")
198 virtual void SetReplicationPaused(bool InbIsReplicationPaused)
199 {
201 bIsReplicationPaused = InbIsReplicationPaused;
203 }
204
206 UE_DEPRECATED(5.3, "Replication pausing is deprecated and will be removed")
207 virtual bool IsReplicationPaused()
208 {
210 return bIsReplicationPaused;
212 }
213
214private:
215
217 ENGINE_API int32 SendRawBunch(FOutBunch* Bunch, bool Merge, const FNetTraceCollector* Collector = nullptr);
218
221
223 ENGINE_API bool ReceivedNextBunch( FInBunch & Bunch, bool & bOutSkipAck );
224};
#define PURE_VIRTUAL(func,...)
Definition CoreMiscDefines.h:103
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
EChannelCloseReason
Definition CoreNetTypes.h:49
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EChannelCreateFlags
Definition Channel.h:41
const int MAX_STRING_SERIALIZE_SIZE
Definition Channel.h:19
EChannelType
Definition Channel.h:25
@ CHTYPE_Control
Definition Channel.h:27
@ CHTYPE_MAX
Definition Channel.h:34
@ CHTYPE_File
Definition Channel.h:31
@ CHTYPE_Actor
Definition Channel.h:28
@ CHTYPE_Voice
Definition Channel.h:33
@ CHTYPE_None
Definition Channel.h:26
EChannelGetAdditionalRequiredBunchesFlags
Definition Channel.h:48
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
JsonWriter Close()
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
void Init()
Definition LockFreeList.h:4
#define LLM_DECLARE_TAG_API(...)
Definition LowLevelMemTracker.h:1117
@ NAME_SIZE
Definition NameTypes.h:57
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition DataBunch.h:127
Definition NameTypes.h:617
Definition DataBunch.h:24
Definition Array.h:670
Definition Channel.h:63
virtual bool CanStopTicking() const
Definition Channel.h:129
virtual void ReceivedBunch(FInBunch &Bunch) PURE_VIRTUAL(UChannel virtual ENGINE_API void ReceivedAck(int32 AckPacketId)
Definition Channel.h:120
virtual void StartBecomingDormant()
Definition Channel.h:177
Definition NetConnection.h:284
virtual ENGINE_API FString Describe()
Definition NetConnection.cpp:1344
void ReceivedNak(int32 NakPacketId)
Definition NetConnection.cpp:2751
virtual ENGINE_API bool IsNetReady() const
Definition NetConnection.cpp:2651
ENGINE_API int32 SendRawBunch(FOutBunch &Bunch, bool InAllowMerge, const FNetTraceCollector *BunchCollector)
Definition NetConnection.cpp:4391
virtual ENGINE_API void CleanUp()
Definition NetConnection.cpp:1364
Definition Object.h:95
virtual COREUOBJECT_API void BeginDestroy()
Definition Obj.cpp:1071
@ false
Definition radaudio_common.h:23
Definition CoreNet.h:259
Definition ObjectPtr.h:488