Get channel details

Unreal Chat SDK has several methods that allow you to get different channel-related data.

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.

Get channel

Fetch details of a specific channel using the GetChannel() method.

Method signature

Output

TypeDescription
UPubnubChannel*
Object returning either the new channel metadata or null value if the channel doesn't exist.

Sample code

Fetch the support channel metadata.

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
9UPubnubChannel* Channel = Chat->GetChannel("support");

Get channel ID

GetChannelID is a getter method that returns the current chat user's ID.

Method signature

Output

TypeDescription
FString*
Returned channel ID.

Sample code

Return the ID of the channel support.

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
9UPubnubChannel* Channel = Chat->GetChannel("support");
10
11FString ChannelID = Channel->GetChannelID();

Get channel data

GetChannelData is a getter method that returns the current chat user's data.

Method signature

Output

TypeDescription
FPubnubChatChannelData*
Returned channel data.

Sample code

Return channel data from 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
9UPubnubChannel* Channel = Chat->GetChannel("support");
10
11FPubnubChatChannelData* ChannelData = Channel->GetChannelData();
Last updated on