Manage message updates
Requires Message Persistence
Enable Message Persistence in the Admin Portal.
Edit messages and receive real-time update events.
Edit messages
EditText() replaces an existing message's content.
Method signature
- Blueprint
- C++ / Input parameters
1Message->EditText(FString NewText);
| Parameter | Description |
|---|---|
newText *Type: stringDefault: n/a | New/updated text that you want to add in place of the existing message. |
Output
This method doesn't return anything.
Sample code
Correct the number of the support ticket you sent to 78398.
1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("support");
10
11FString Timetoken = "16200000000000001";
12
13// Fetch the message
14UPubnubMessage* Message = Channel->GetMessage(Timetoken);
15
show all 16 linesGet message updates
Receive real-time updates when messages or reactions change:
StreamUpdates()- updates for a singleMessageobjectStreamUpdatesOn()- updates for multipleMessageobjects
Both return a stop object to unsubscribe.
Stream update behavior
StreamUpdates()returns the entire updatedMessageon each changeStreamUpdatesOn()returns the complete list of monitored messages on each change
Method signature
- Blueprint
- C++ / Input parameters
-
StreamUpdates()1Message->StreamUpdates(FOnPubnubMessageStreamUpdateReceived MessageUpdateCallback); -
StreamUpdatesOn()1Message->StreamUpdatesOn(
2 TArray<UPubnubMessage*> Messages,
3 FOnPubnubMessageStreamUpdateReceived MessageUpdateCallback
4);
| Parameter | Required in StreamUpdates() | Required in StreamUpdatesOn() | Description |
|---|---|---|---|
MessagesType: TArray<UPubnubMessage*>Default: n/a | No | Yes | Array of Message objects for which you want to get updates. |
MessageUpdateCallbackType: FOnPubnubMessageStreamUpdateReceivedDefault: n/a | Yes | Yes | 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. |
Sample code
-
StreamUpdates()Get message and message reaction-related updates for the message with the timetoken
16200000000000000published on thesupportchannel.
show all 21 lines1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("support");
10
11FString Timetoken = "16200000000000000";
12
13// Fetch the message
14UPubnubMessage* Message = Channel->GetMessage(Timetoken);
15 -
StreamUpdatesOn()Get message and message reaction-related updates for several messages published on the
supportchannel.
show all 23 lines1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("support");
10 // Get the channels and save the reference
11UPubnubMessage* Message1 = Channel->GetMessage("16200000000000000");
12UPubnubMessage* Message2 = Channel->GetMessage("16200000000000001");
13
14TArray<UPubnubMessage*> Messages;
15Messages.Add(Message1);
Other examples
-
StreamUpdates()Stop listening to updates for the message with the timetoken
16200000000000000published on thesupportchannel.1auto StopUpdates = Message->StreamUpdates(StreamUpdatesResponse);
2
3StopUpdates->Stop(); -
StreamUpdatesOn()Stop listening to updates for the last ten messages published on the
supportchannel.1auto StopUpdates = Message->StreamUpdatesOn(Messages, MessagesStreamUpdatesResponse);
2
3StopUpdates->Stop();