Manage message updates

Edit messages and receive events whenever someone edits them.

icon

Usage in Blueprints and C++


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

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 lines

Get 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 single Message object.
  • StreamUpdatesOn() checks message and message reaction-related updates on a list of Message 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

icon

Handle the response


Output

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

    #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);

    show all 21 lines
  • StreamUpdatesOn()

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

    #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);
    show all 23 lines

Other examples

  • StreamUpdates()

    Stop listening to updates for the message with the timetoken 16200000000000000 published on the support 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();
Last updated on