Manage message updates
Edit messages and receive events whenever someone edits them.
Requires Message Persistence
To manage messages in PubNub storage, you must enable Message Persistence for your app's keyset in the Admin Portal.
Edit messages
Change the content of the existing message to a new one using the EditText()
method.
Method signature
- Blueprint
- C++ / Input parameters
Message->EditText(FString NewText);
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
newText | string | Yes | n/a | New/updated text that you want to add in place of the existing message. |
Output
This method doesn't return anything.
Basic usage
Correct the number of the support ticket you sent to 78398
.
#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
UPubnubChannel* Channel = Chat->GetChannel("support");
FString Timetoken = "16200000000000001";
// Fetch the message
UPubnubMessage* Message = Channel->GetMessage(Timetoken);
show all 16 linesGet message updates
You can receive updates when specific messages and related message reactions are added, edited, or removed on other clients using the following methods:
StreamUpdates()
checks message and message reaction-related updates on a singleMessage
object.StreamUpdatesOn()
checks message and message reaction-related updates on a list ofMessage
objects.
Both methods accept a callback function as an argument. The Unreal Chat SDK invokes this callback whenever someone adds, edits or deletes a message, or adds or removes a message reaction to/from the specific message(s).
Underneath, these methods subscribe the current user to a channel and add a message reactions event listener to receive all messageAction
events of type added
or removed
. These methods also return the unsubscribe
function you can invoke to stop receiving messageAction
events and unsubscribe from the channel.
Method signature
- Blueprint
- C++ / Input parameters
-
StreamUpdates()
Message->StreamUpdates(FOnPubnubMessageStreamUpdateReceived MessageUpdateCallback);
-
StreamUpdatesOn()
Message->StreamUpdatesOn(
TArray<UPubnubMessage*> Messages,
FOnPubnubMessageStreamUpdateReceived MessageUpdateCallback
);
Parameter | Type | Required in StreamUpdates() | Required in StreamUpdatesOn() | Default | Description |
---|---|---|---|---|---|
Messages | TArray<UPubnubMessage*> | No | Yes | n/a | Array of Message objects for which you want to get updates. |
MessageUpdateCallback | FOnPubnubMessageStreamUpdateReceived | Yes | Yes | n/a | Callback function passed as a parameter to both methods. It defines the custom behavior to be executed when detecting channel metadata changes. |
Output
Type | Description |
---|---|
UPubnubCallbackStop* | Object on which you can call Stop() to stop receiving updates. |
Basic usage
-
StreamUpdates()
Get message and message reaction-related updates for the message with the timetoken
16200000000000000
published on thesupport
channel.
show all 21 lines#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
UPubnubChannel* Channel = Chat->GetChannel("support");
FString Timetoken = "16200000000000000";
// Fetch the message
UPubnubMessage* Message = Channel->GetMessage(Timetoken); -
StreamUpdatesOn()
Get message and message reaction-related updates for several messages published on the
support
channel.
show all 23 lines#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
UPubnubChannel* Channel = Chat->GetChannel("support");
// Get the channels and save the reference
UPubnubMessage* Message1 = Channel->GetMessage("16200000000000000");
UPubnubMessage* Message2 = Channel->GetMessage("16200000000000001");
TArray<UPubnubMessage*> Messages;
Messages.Add(Message1);
Other examples
-
StreamUpdates()
Stop listening to updates for the message with the timetoken
16200000000000000
published on thesupport
channel.auto StopUpdates = Message->StreamUpdates(StreamUpdatesResponse);
StopUpdates->Stop(); -
StreamUpdatesOn()
Stop listening to updates for the last ten messages published on the
support
channel.auto StopUpdates = Message->StreamUpdatesOn(Messages, MessagesStreamUpdatesResponse);
StopUpdates->Stop();