On this page

Manage message updates

Requires Message Persistence

Edit messages and receive real-time update events.

icon

Usage in Blueprints and C++


Edit messages

EditText() replaces an existing message's content.

Method signature

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 lines

Get message updates

Receive real-time updates when messages or reactions change:

  • StreamUpdates() - updates for a single Message object
  • StreamUpdatesOn() - updates for multiple Message objects

Both return a stop object to unsubscribe.

Stream update behavior
  • StreamUpdates() returns the entire updated Message on each change
  • StreamUpdatesOn() returns the complete list of monitored messages on each change

Method signature

icon

Handle the response


Output

TypeDescription
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 16200000000000000 published on the support channel.

    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 = "16200000000000000";
    12
    13// Fetch the message
    14UPubnubMessage* Message = Channel->GetMessage(Timetoken);
    15
    show all 21 lines
  • StreamUpdatesOn()

    Get message and message reaction-related updates for several messages published on the support channel.

    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 // Get the channels and save the reference
    11UPubnubMessage* Message1 = Channel->GetMessage("16200000000000000");
    12UPubnubMessage* Message2 = Channel->GetMessage("16200000000000001");
    13
    14TArray<UPubnubMessage*> Messages;
    15Messages.Add(Message1);
    show all 23 lines

Other examples

  • StreamUpdates()

    Stop listening to updates for the message with the timetoken 16200000000000000 published on the support channel.

    1auto StopUpdates = Message->StreamUpdates(StreamUpdatesResponse);
    2
    3StopUpdates->Stop();
  • StreamUpdatesOn()

    Stop listening to updates for the last ten messages published on the support channel.

    1auto StopUpdates = Message->StreamUpdatesOn(Messages, MessagesStreamUpdatesResponse);
    2
    3StopUpdates->Stop();
Last updated on