Manage user updates

Update user details and receive events whenever someone updates them.

icon

Usage in Blueprints and C++


Requires App Context

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

Update user details

You can edit the metadata of an existing user with Update() and UpdateUser().

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

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.

Basic usage

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

  • Update()

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

    // Define user ID
    FString UserID = "support_agent_15";
    UPubnubUser* User = Chat->GetUser(UserID);

    FPubnubChatUserData UserData;
    UserData.CustomDataJson = "{\"LinkedIn\":\"https://www.linkedin.com/mkelly_vp2\"}";

    show all 17 lines
  • UpdateUser()

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

    // Define user ID
    FString UserID = "support_agent_15";

    FPubnubChatUserData UserData;
    UserData.CustomDataJson = "{\"LinkedIn\":\"https://www.linkedin.com/mkelly_vp2\"}";

    // Update the user and save the reference
    show all 16 lines

Get user updates

Two methods let you receive updates about users (user IDs) added, edited, or removed on other clients:

  • StreamUpdates() checks updates on a single User object.
  • StreamUpdatesOn() checks updates on a list of User objects.

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

Underneath, these methods subscribe the current user to a channel and add an objects event listener to receive all objects (known as App Context) events of type uuid. 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

Get updates on support_agent_15.

  • StreamUpdates()

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

    // Define user ID
    FString UserID = "support_agent_15";

    // Get the user and save the reference
    UPubnubUser* User = Chat->GetUser(UserID);

    // Create a pubnub response delegate
    show all 20 lines

Get updates on support_agent_15 and support-manager.

  • StreamUpdatesOn()

    #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 users and save the reference
    UPubnubUser* User1 = Chat->GetUser("support_agent_15");
    UPubnubUser* User2 = Chat->GetUser("support-manager");

    TArray<UPubnubUser*> Users;
    Users.Add(User1);
    Users.Add(User2);
    show all 22 lines

Other examples

Stop listening to updates on support_agent_15.

  • StreamUpdates()

    auto StopUpdates = User->StreamUpdates(StreamUpdatesResponse);

    StopUpdates->Stop();

Stop listening to updates on support_agent_15 and support-manager.

  • StreamUpdatesOn()

    auto StopUpdates = User->StreamUpdatesOn(Users, StreamUpdatesOnResponse);

    StopUpdates->Stop();
Last updated on