Manage channel updates
Update channel metadata and receive real-time change events.
Asynchronous and synchronous method execution
Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.
-
Asynchronous methods (
Asyncsuffix) returnvoidand take an optional delegate parameter that fires when the operation completes.1Channel->UpdateAsync(UpdateData, OnUpdateResponseDelegate);You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the
Nativesuffix (for example,FOnPubnubChatChannelResponseNative). -
Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.
1FPubnubChatOperationResult Result = Channel->Update(UpdateData);
Requires App Context
Enable App Context for your keyset in the Admin Portal.
Update channel details
Edit channel metadata with Update() or UpdateChannel().
Both methods produce the same result. Call Update() on a Channel object or UpdateChannel() on the Chat object with the channel ID.
Method signature
- C++ / Input parameters
- Blueprint
-
Channel->Update()1Channel->Update(FPubnubChatUpdateChannelInputData UpdateData); -
Chat->UpdateChannel()1Chat->UpdateChannel(
2 FString ChannelID,
3 FPubnubChatUpdateChannelInputData UpdateData
4);
| Parameter | Required in Channel->Update() | Required in Chat->UpdateChannel() | Description |
|---|---|---|---|
ChannelIDType: FStringDefault: n/a | No | Yes | Unique channel identifier. |
UpdateDataDefault: n/a | No | No | Information about the channel. |
FPubnubChatUpdateChannelInputData
| Parameter | Description |
|---|---|
ChannelNameType: FStringDefault: n/a | Display name for the channel (must not be empty or consist only of whitespace characters). |
DescriptionType: FStringDefault: n/a | Detailed description of the channel's purpose or topic. |
CustomType: FStringDefault: n/a | JSON providing custom data about the channel. Values must be scalar only; arrays or objects are not supported. Filtering App Context data through the custom property is not recommended in SDKs. |
StatusType: FStringDefault: n/a | Tag that lets you categorize your app channels by their current state. The tag choice is entirely up to you and depends on your use case. |
TypeType: FStringDefault: n/a | Tag that lets you categorize your app channels by their functional roles. The tag choice is entirely up to you and depends on your use case. |
ForceSetChannelNameType: boolDefault: false | When true, overwrites the channel name even if empty. |
ForceSetDescriptionType: boolDefault: false | When true, overwrites the description even if empty. |
ForceSetCustomType: boolDefault: false | When true, overwrites the custom data even if empty. |
ForceSetStatusType: boolDefault: false | When true, overwrites the status even if empty. |
ForceSetTypeType: boolDefault: false | When true, overwrites the type even if empty. |
Output
| Method | Description |
|---|---|
Channel->Update()Type: FPubnubChatOperationResult | Contains Error (bool) and ErrorMessage (FString). Check Error to determine if the operation succeeded. |
Chat->UpdateChannel()Type: FPubnubChatChannelResult | Contains Result (FPubnubChatOperationResult) and Channel (UPubnubChatChannel*). |
Sample code
Reference code
This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code. Use it as a reference when working with other examples in this document.
Update channel metadata asynchronously.
Update channel from the Chat object
Get channel updates
Receive updates when Channel objects are edited or removed:
StreamUpdates()- monitors a single channelStreamUpdatesOn()- monitors multiple channels (static method)
Both methods return FPubnubChatOperationResult. Updates are delivered via the channel's OnUpdated delegate (with channel ID and data) and deletions via the OnDeleted delegate. Bind these delegates before calling StreamUpdates() or StreamUpdatesOn().
Stream update behavior
-
StreamUpdates()delivers updates via the channel'sOnUpdateddelegate (with channel ID and data) and deletions viaOnDeleteddelegate. -
StreamUpdatesOn()delivers updates on any of the monitored channels via the same delegate pattern. -
To stop receiving updates, call
StopStreamingUpdates()orStopStreamingUpdatesAsync()on the channel.
Method signature
- C++ / Input parameters
- Blueprint
-
StreamUpdates()1Channel->StreamUpdates(); -
StreamUpdatesOn()(static)1UPubnubChatChannel::StreamUpdatesOn(const TArray<UPubnubChatChannel*>& Channels);
| Parameter | Required in StreamUpdates() | Required in StreamUpdatesOn() | Description |
|---|---|---|---|
ChannelsType: TArray<UPubnubChatChannel*>Default: n/a | No | Yes | Array of Channel objects for which you want to get updates. |
Output
| Type | Description |
|---|---|
FPubnubChatOperationResult | Contains Error (bool) and ErrorMessage (FString). Check Error to determine if the operation succeeded. |
EPubnubChatStreamedUpdateType
The EPubnubChatStreamedUpdateType enum describes the kind of streamed update. In C++, updates and deletions are delivered via separate delegates (OnUpdated and OnDeleted). In Blueprints, this enum may appear in event dispatchers to distinguish between the two.
| Value | Description |
|---|---|
PCSUT_Updated | The entity's metadata was updated. |
PCSUT_Deleted | The entity was deleted. |
This enum applies to all entities that support StreamUpdates() (Channel, User, Message, Membership).
Sample code
Get updates on the support channel.
- C++
- Blueprint
1
Stopping updates
To stop receiving channel updates, call StopStreamingUpdates() or StopStreamingUpdatesAsync() on the channel.