Manage message updates
Requires Message Persistence
Enable Message Persistence in the Admin Portal.
Edit messages and receive real-time update 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.1Message->EditTextAsync(NewText, OnEditTextResponseDelegate);You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the
Nativesuffix (for example,FOnPubnubChatOperationResponseNative). -
Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.
1FPubnubChatOperationResult Result = Message->EditText(NewText);
Edit messages
EditText() replaces an existing message's content.
Method signature
- Blueprint
- C++ / Input parameters
1Message->EditText(FString NewText);
NewTextrequired#- New/updated text that you want to add in place of the existing message.
Output
| Type | Description |
|---|---|
FPubnubChatOperationResult | Result of the operation. Check Error and ErrorMessage for failure. |
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.
Edit message text asynchronously.
Get message updates
Receive real-time updates when messages or reactions change:
StreamUpdates()- updates for a singleMessageobjectStreamUpdatesOn()- updates for multipleMessageobjects
Bind the message's OnUpdated delegate (Blueprint) or OnUpdatedNative delegate (C++) before calling StreamUpdates(). Call StopStreamingUpdates() to stop receiving updates.
Stream update behavior
StreamUpdates()fires the message'sOnUpdateddelegate with(FString Timetoken, FPubnubChatMessageData MessageData)on each change.StreamUpdatesOn()is a static method that callsStreamUpdates()on each message in the array. Each message fires its ownOnUpdateddelegate individually.
Method signature
- Blueprint
- C++ / Input parameters
-
StreamUpdates()1Message->StreamUpdates(); -
StreamUpdatesOn()1UPubnubChatMessage::StreamUpdatesOn(TArray<UPubnubChatMessage*> Messages); -
StopStreamingUpdates()1Message->StopStreamingUpdates();
Messages#- Array of
Messageobjects for which you want to get updates.- Required in StreamUpdatesOn()
- Yes
Output
StreamUpdates()#- Result of the operation. Check
Errorfor failure.- Return type
FPubnubChatOperationResult
StreamUpdatesOn()#- Result of the operation. Check
Errorfor failure.- Return type
FPubnubChatOperationResult
StopStreamingUpdates()#- Result of the operation. Check
Errorfor failure.- Return type
FPubnubChatOperationResult
Sample code
-
StreamUpdates()Get message and message reaction-related updates for a message published on the
supportchannel.
- C++
- Blueprint
1
Other examples
Stop listening to updates for a message.
Actor.h
1
Actor.cpp
1