On this page

Manage user updates

Update user details and receive real-time update events.

icon

Usage in Blueprints and C++


Requires App Context

Enable App Context in the Admin Portal to store user data.

Update user details

Edit user metadata with Update() or UpdateUser().

  • Update() - call on a User object (no ID needed)
  • UpdateUser() - call on a Chat object (requires user ID)

Method signature

API limits

To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.

Output

TypeDescription
UPubnubUser*
Returned object containing the updated user metadata.

Sample code

Change the link to the user's support_agent_15 LinkedIn profile to https://www.linkedin.com/mkelly_vp2.

  • Update()

    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// Define user ID
    10FString UserID = "support_agent_15";
    11UPubnubUser* User = Chat->GetUser(UserID);
    12
    13FPubnubChatUserData UserData;
    14UserData.CustomDataJson = "{\"LinkedIn\":\"https://www.linkedin.com/mkelly_vp2\"}";
    15
    show all 17 lines
  • UpdateUser()

    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// Define user ID
    10FString UserID = "support_agent_15";
    11
    12FPubnubChatUserData UserData;
    13UserData.CustomDataJson = "{\"LinkedIn\":\"https://www.linkedin.com/mkelly_vp2\"}";
    14
    15// Update the user and save the reference
    show all 16 lines

Get user updates

Receive updates when User objects are edited or removed:

  • StreamUpdates() - monitors a single user
  • StreamUpdatesOn() - monitors multiple users

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

Callback behavior
  • StreamUpdates() - returns updated User object (nullptr if deleted)
  • StreamUpdatesOn() - returns complete list of monitored users 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

Get updates on support_agent_15.

  • StreamUpdates()

    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// Define user ID
    10FString UserID = "support_agent_15";
    11
    12// Get the user and save the reference
    13UPubnubUser* User = Chat->GetUser(UserID);
    14
    15// Create a pubnub response delegate
    show all 20 lines

Get updates on support_agent_15 and support-manager.

  • StreamUpdatesOn()

    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 users and save the reference
    10UPubnubUser* User1 = Chat->GetUser("support_agent_15");
    11UPubnubUser* User2 = Chat->GetUser("support-manager");
    12
    13TArray<UPubnubUser*> Users;
    14Users.Add(User1);
    15Users.Add(User2);
    show all 22 lines

Other examples

Stop listening to updates on support_agent_15.

  • StreamUpdates()

    1auto StopUpdates = User->StreamUpdates(StreamUpdatesResponse);
    2
    3StopUpdates->Stop();

Stop listening to updates on support_agent_15 and support-manager.

  • StreamUpdatesOn()

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