Channel Groups API for PubNub Unreal SDK
Channel groups allow PubNub developers to bundle thousands of channels into a group that can be identified by a name. These channel groups can then be subscribed to, receiving data from the many back-end channels the channel group contains.
Channel group operations
You can't publish to a channel group. You can only subscribe to it. To publish within the channel group, you need to publish to each channel individually.
Add Channels
Requires Stream Controller add-on
This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.
This function adds a channel to a channel group.
Method(s)
Adding Channels
is accomplished by using the following method(s) in the Unreal SDK:
Maximum number of channels
200 channels
can be added to the channel group
per API call.
- Blueprint
- C++
PubnubSubsystem->AddChannelToGroup(
FString ChannelName,
FString ChannelGroup
);
Parameter | Type | Required | Description |
---|---|---|---|
ChannelName | FString | Yes | The channel to add to the channel group. |
ChannelGroup | FString | Yes | The channel group to add the channels to. |
Basic Usage
#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();
FString ChannelName = "randomChannel";
FString ChanelGroup = "myChannelGroup";
// Add channel to channel group
PubnubSubsystem->AddChannelToGroup(ChannelName, ChannelGroup);
Returns
This method doesn't have any return value.
List Channels
Requires Stream Controller add-on
This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.
This function lists all the channels of the channel group.
Method(s)
- Blueprint
- C++
Response variants
You can also call the ListChannelsFromGroup_JSON()
variant of this method to get an FOnPubnubResponse
which contains pure JSON.
Response variants
You can also call the ListChannelsFromGroup_JSON()
variant of this method to get an FOnPubnubResponse
which contains pure JSON.
PubnubSubsystem->ListChannelsFromGroup(
FString ChannelGroup,
FOnListChannelsFromGroupResponse OnListChannelsResponse
);
Parameter | Type | Required | Description |
---|---|---|---|
ChannelGroup | FString | Yes | The channel group to list the channels of. |
OnListChannelsResponse | FOnListChannelsFromGroupResponse | Yes | The callback function used to handle the result. |
Basic Usage
#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();
FString ChannelName = "randomChannel";
FString ChannelGroup = "myChannelGroup";
// Create a pubnub response delegate
// you MUST implement your own callback function to handle the response
FOnListChannelsFromGroupResponse OnListChannelsResponse;
OnListChannelsResponse.BindDynamic(this, &AMyActor::OnListChannelsResponse);
// Add channel to channel group
show all 16 linesReturns
This method returns the FOnListChannelsFromGroupResponse
struct.
FOnListChannelsFromGroupResponse
Field | Type | Description |
---|---|---|
Error | bool | Whether the operation resulted in an error. |
Status | int | HTTP code of the result of the operation. |
Channels | TArray<FString>& | An array of channel names of all the channels of the channel group. |
JSON response
{
"error":false,
"payload":{
"channels":[],
"group":"my_channel"
},
"service":"channel-registry",
"status":200
}
Remove Channels
Requires Stream Controller add-on
This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.
This function removes the channels from the channel group.
Method(s)
- Blueprint
- C++
PubnubSubsystem->RemoveChannelFromGroup(
FString ChannelName,
FString ChannelGroup
);
Parameter | Type | Required | Description |
---|---|---|---|
ChannelGroup | FString | Yes | The channel group to remove the channel from. |
ChannelName | FString | Yes | The channel to remove from the channel group. |
Basic Usage
#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();
FString ChannelName = "randomChannel";
FString ChanelGroup = "myChannelGroup";
// Remove channel from channel group
PubnubSubsystem->RemoveChannelFromGroup(ChannelName, ChannelGroup);
Returns
This method doesn't have any return value.
Delete Channel Group
Requires Stream Controller add-on
This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.
This function removes the channel group.
Method(s)
- Blueprint
- C++
PubnubSubsystem->RemoveChannelGroup(
String ChannelGroup
);
Parameter | Type | Required | Description |
---|---|---|---|
ChannelGroup | FString | Yes | The channel group to remove. |
Basic Usage
#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();
FString ChanelGroup = "myChannelGroup";
// Remove channel group
PubnubSubsystem->RemoveChannelGroup(ChannelGroup);
Returns
This method doesn't have any return value.