On this page

Manage channel updates

Update channel metadata and receive real-time change events.

icon

Usage in Blueprints and C++


Asynchronous and synchronous method execution

Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.

  • Asynchronous methods (Async suffix) return void and 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 Native suffix (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

  • Channel->Update()

    1Channel->Update(FPubnubChatUpdateChannelInputData UpdateData);
  • Chat->UpdateChannel()

    1Chat->UpdateChannel(
    2 FString ChannelID,
    3 FPubnubChatUpdateChannelInputData UpdateData
    4);
ParameterRequired in Channel->Update()Required in Chat->UpdateChannel()Description
ChannelID
Type: FString
Default:
n/a
No
Yes
Unique channel identifier.
UpdateDataNo
No
Information about the channel.

FPubnubChatUpdateChannelInputData


* required
ParameterDescription
ChannelName
Type: FString
Default:
n/a
Display name for the channel (must not be empty or consist only of whitespace characters).
Description
Type: FString
Default:
n/a
Detailed description of the channel's purpose or topic.
Custom
Type: FString
Default:
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.
Status
Type: FString
Default:
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.
Type
Type: FString
Default:
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.
ForceSetChannelName
Type: bool
Default:
false
When true, overwrites the channel name even if empty.
ForceSetDescription
Type: bool
Default:
false
When true, overwrites the description even if empty.
ForceSetCustom
Type: bool
Default:
false
When true, overwrites the custom data even if empty.
ForceSetStatus
Type: bool
Default:
false
When true, overwrites the status even if empty.
ForceSetType
Type: bool
Default:
false
When true, overwrites the type even if empty.

Output

MethodDescription
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.

Actor.h
1

Actor.cpp
1

Update channel from the Chat object

Get channel updates

Receive updates when Channel objects are edited or removed:

  • StreamUpdates() - monitors a single channel
  • StreamUpdatesOn() - 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's OnUpdated delegate (with channel ID and data) and deletions via OnDeleted delegate.

  • StreamUpdatesOn() delivers updates on any of the monitored channels via the same delegate pattern.

  • To stop receiving updates, call StopStreamingUpdates() or StopStreamingUpdatesAsync() on the channel.

Method signature

  • StreamUpdates()

    1Channel->StreamUpdates();
  • StreamUpdatesOn() (static)

    1UPubnubChatChannel::StreamUpdatesOn(const TArray<UPubnubChatChannel*>& Channels);
ParameterRequired in StreamUpdates()Required in StreamUpdatesOn()Description
Channels
Type: TArray<UPubnubChatChannel*>
Default:
n/a
No
Yes
Array of Channel objects for which you want to get updates.

Output

TypeDescription
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.

ValueDescription
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.

1

Stopping updates

To stop receiving channel updates, call StopStreamingUpdates() or StopStreamingUpdatesAsync() on the channel.