On this page

Manage channel updates

Update channel metadata and receive real-time change events.

icon

Usage in Blueprints and C++


Requires App Context

Enable App Context for your keyset in the Admin Portal.

Update channel details

Edit channel metadata with Update() or UpdateChannel().

Both methods produce the same result. Call Update() on a Channel object or UpdateChannel() on the Chat object with the channel ID.

Method signature

Output

TypeDescription
UPubnubChannel*
Object returning the updated channel metadata.

Sample code

Update the description of the support channel.

  • Update()

    1#include "Kismet/GameplayStatics.h"
    2#include "PubnubChatSubsystem.h"
    3
    4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(ContextObject);
    5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
    6
    7UPubnubChat* Chat = PubnubChatSubsystem->InitChat("demo", "demo", "my_user");
    8
    9UPubnubChannel* Channel = Chat->GetChannel("support");
    10
    11// Define the channel data
    12FPubnubChatChannelData ChannelData;
    13ChannelData.Description = "Channel for CRM tickets";
    14
    15Channel->Update(ChannelData);
  • UpdateChannel()

    1#include "Kismet/GameplayStatics.h"
    2#include "PubnubChatSubsystem.h"
    3
    4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(ContextObject);
    5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
    6
    7UPubnubChat* Chat = PubnubChatSubsystem->InitChat("demo", "demo", "my_user");
    8
    9// Define the channel data
    10FPubnubChatChannelData ChannelData;
    11ChannelData.Description = "Channel for CRM tickets";
    12
    13Chat->UpdateChannel("support", ChannelData);

Get channel updates

Receive updates when Channel objects are edited or removed:

  • StreamUpdates() - monitors a single channel
  • StreamUpdatesOn() - monitors multiple channels

Both methods accept a callback invoked when channel metadata changes. They subscribe to a channel and add an objects event listener for channel events, returning an unsubscribe function.

Stream update behavior
  • StreamUpdates() returns the updated Channel object on each change (nullptr if deleted)
  • StreamUpdatesOn() returns the complete list of monitored channels on any 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 updates 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
    9// Get the channel and save the reference
    10UPubnubChannel* Channel = Chat->GetChannel("support");
    11
    12// Create a pubnub response delegate
    13// you MUST implement your own callback function to handle the response
    14FOnPubnubChannelStreamUpdateReceived StreamUpdatesResponse;
    15StreamUpdatesResponse.BindDynamic(this, &AMyActor::OnChannelUpdateResponseReceived);
    show all 17 lines
  • StreamUpdatesOn()

    Get updates on the support and incident-management channels.

    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
    9// Get the channels and save the reference
    10UPubnubChannel* Channel1 = Chat->GetChannel("support");
    11UPubnubChannel* Channel2 = Chat->GetChannel("incident-management");
    12
    13TArray<UPubnubChannel*> Channels;
    14Channels.Add(Channel1);
    15Channels.Add(Channel2);
    show all 22 lines

Other examples

  • StreamUpdates()

    Stop listening to updates on the support channel.

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

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

    1auto StopUpdates = Channel->StreamUpdatesOn(Channels, StreamUpdatesOnResponse);
    2
    3StopUpdates->Stop();
Last updated on