ChannelMetadata Entity

As of version 1.1.0, the Unreal Engine software development kit (SDK) supports entities. Entities are SDK objects that bundle operations for a specific resource type and simplify working with PubNub application programming interfaces (APIs).

Use entities to perform common tasks without manually wiring requests. Some PubNub APIs are exposed via entities. Other operations remain available on the PubnubSubsystem object.

Create ChannelMetadata

Use this factory method to return a local ChannelMetadata entity for a single channel metadata object. A ChannelMetadata entity centralizes operations related to App Context channel metadata.

UPubnubChannelMetadataEntity* CreateChannelMetadataEntity(FString Channel);
* required
ParameterDescription
Channel *
Type: FString
Identifier of the channel metadata for which to create the entity.

Sample code

Reference code
This example is a self-contained code snippet ready to be run. It includes necessary imports and executes methods with console logging. Use it as a reference when working with other examples in this document.
// Get PubnubSubsystem from GameInstance
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

// Set UserID
FString UserID = TEXT("Player_001");
PubnubSubsystem->SetUserID(UserID);

// Create a channel metadata entity for the channel you want to monitor metadata changes
FString ChannelName = TEXT("lobby_settings");
UPubnubChannelMetadataEntity* ChannelMetadataEntity = PubnubSubsystem->CreateChannelMetadataEntity(ChannelName);

Available operations

The ChannelMetadata entity provides operations for PubNub App Context channel metadata.

Operation (click for more information)Description
CreateSubscription(SubscribeSettings)
Returns a local channel metadata subscription object with optional parameters. You can then subscribe to receive real-time updates for that channel metadata.
SetChannelMetadata(ChannelMetadata, OnSetChannelMetadataResponse, Include)
Sets metadata for a specified channel in the PubNub App Context. Requires the App Context add-on.
GetChannelMetadata(OnGetChannelMetadataResponse, Include)
Retrieves metadata for a specified channel from the PubNub App Context. Requires the App Context add-on.
RemoveChannelMetadata(OnRemoveChannelMetadataResponse)
Removes all metadata associated with a specified channel from the PubNub App Context. Requires the App Context add-on.
Last updated on