Manage channel updates

Update channel details and receive events whenever someone updates them.

icon

Usage in Blueprints and C++


Requires App Context

To store data about channels, you must enable App Context for your app's keyset in the Admin Portal.

Update channel details

You can edit the metadata of an existing channel with Update() and UpdateChannel().

Both of them give the same output. The only difference is that you call a given method either on the Chat (UpdateChannel()) or the Channel (Update()) object. Depending on the object, these methods take a different set of input parameters - you either have to specify the channel ID you want to update or not because it's already known.

Method signature

Output

TypeDescription
UPubnubChannel*Object returning the updated channel metadata.

Basic usage

Update the description of the support channel.

  • Update()

    #include "Kismet/GameplayStatics.h"
    #include "PubnubChatSubsystem.h"

    UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(ContextObject);
    UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();

    UPubnubChat* Chat = PubnubChatSubsystem->InitChat("demo", "demo", "my_user");

    UPubnubChannel* Channel = Chat->GetChannel("support");

    // Define the channel data
    FPubnubChatChannelData ChannelData;
    ChannelData.Description = "Channel for CRM tickets";

    Channel->Update(ChannelData);
  • UpdateChannel()

    #include "Kismet/GameplayStatics.h"
    #include "PubnubChatSubsystem.h"

    UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(ContextObject);
    UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();

    UPubnubChat* Chat = PubnubChatSubsystem->InitChat("demo", "demo", "my_user");

    // Define the channel data
    FPubnubChatChannelData ChannelData;
    ChannelData.Description = "Channel for CRM tickets";

    Chat->UpdateChannel("support", ChannelData);

Get channel updates

You can receive updates when specific Channel object(s) are edited or removed on other clients using the following methods:

  • StreamUpdates() checks updates on a single Channel object.
  • StreamUpdatesOn() checks updates on a Channel object list.

Both methods accept a callback function as an argument. The Unreal Chat SDK invokes this callback whenever someone adds, changes, or removes channel metadata.

Underneath, these methods subscribe the current user to a channel and add an objects event listener to receive all objects events of type channel. These methods also return the unsubscribe function you can invoke to stop receiving objects 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 updates 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");

    // Get the channel and save the reference
    UPubnubChannel* Channel = Chat->GetChannel("support");

    // Create a pubnub response delegate
    // you MUST implement your own callback function to handle the response
    FOnPubnubChannelStreamUpdateReceived StreamUpdatesResponse;
    StreamUpdatesResponse.BindDynamic(this, &AMyActor::OnChannelUpdateResponseReceived);
    show all 17 lines
  • StreamUpdatesOn()

    Get updates on the support and incident-management channels.

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

    // Get the channels and save the reference
    UPubnubChannel* Channel1 = Chat->GetChannel("support");
    UPubnubChannel* Channel2 = Chat->GetChannel("incident-management");

    TArray<UPubnubChannel*> Channels;
    Channels.Add(Channel1);
    Channels.Add(Channel2);
    show all 22 lines

Other examples

  • StreamUpdates()

    Stop listening to updates on the support channel.

    auto StopUpdates = Channel->Channel->StreamUpdates(StreamUpdatesResponse);

    StopUpdates->Stop();
  • StreamUpdatesOn()

    Stop listening to updates on the support and incident-management channels.

    auto StopUpdates = Channel->StreamUpdatesOn(Channels, StreamUpdatesOnResponse);

    StopUpdates->Stop();
Last updated on