Channel Groups API for 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.

icon

Usage in Blueprints and C++

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.

PubnubSubsystem->AddChannelToGroup(
FString Channel,
FString ChannelGroup,
FOnAddChannelToGroupResponse OnAddChannelToGroupResponse
);
* required
ParameterDescription
Channel *
Type: FString
The channel to add to the channel group.
ChannelGroup *
Type: FString
The channel group to add the channels to.
OnAddChannelToGroupResponse *The delegate for the operation's result.

You can also use a native callback of the type FOnAddChannelToGroupResponseNative to handle the result using a lambda.

FOnAddChannelToGroupResponse

FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.

FOnAddChannelToGroupResponseNative

FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h



Actor.cpp



Returns

This method doesn't have any return value.

Other Examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Add channels to a channel group with lambda

You can use a lambda function to handle the response:

Actor.h



Actor.cpp



Add channels to a channel group with result struct

You can use the result struct to handle the response:

Actor.h



Actor.cpp



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)

PubnubSubsystem->ListChannelsFromGroup(
FString ChannelGroup,
FOnListChannelsFromGroupResponse OnListChannelsResponse
);
* required
ParameterDescription
ChannelGroup *
Type: FString
The channel group to list the channels of.
OnListChannelsResponse *The delegate for the operation's result.

You can also use a native callback of the type FOnListChannelsFromGroupResponseNative to handle the result using a lambda.

FOnListChannelsFromGroupResponse

FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
Channels
TArray<FString>&
An array of channel names of all the channels of the channel group.

FOnListChannelsFromGroupResponseNative

FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
Channels
const TArray<FString>&
An array of channel names of all the channels of the channel group.

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h



Actor.cpp



Returns

This function is void, but the delegate returns the FOnListChannelsFromGroupResponse struct.

FOnListChannelsFromGroupResponse


FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
Channels
TArray<FString>&
An array of channel names of all the channels of the channel group.

Other Examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

List channels from a channel group with lambda

You can use a lambda function to handle the response:

Actor.h



Actor.cpp



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)

PubnubSubsystem->RemoveChannelFromGroup(
FString Channel,
FString ChannelGroup,
FOnRemoveChannelFromGroupResponse OnRemoveChannelFromGroupResponse
);
* required
ParameterDescription
ChannelGroup *
Type: FString
The channel group to remove the channel from.
Channel *
Type: FString
The channel to remove from the channel group.
OnRemoveChannelFromGroupResponse *The delegate for the operation's result.

You can also use a native callback of the type FOnRemoveChannelFromGroupResponseNative to handle the result using a lambda.

FOnRemoveChannelFromGroupResponse

FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.

FOnRemoveChannelFromGroupResponseNative

FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h



Actor.cpp



Returns

This method doesn't have any return value.

Other Examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Remove channels from a channel group with lambda

You can use a lambda function to handle the response:

Actor.h



Actor.cpp



Remove channels from a channel group with result struct

You can use the result struct to handle the response:

Actor.h



Actor.cpp



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)

PubnubSubsystem->RemoveChannelGroup(
FString ChannelGroup,
FOnRemoveChannelGroupResponse OnRemoveChannelGroupResponse
);
* required
ParameterDescription
ChannelGroup *
Type: FString
The channel group to remove.
OnRemoveChannelGroupResponse *The delegate for the operation's result.

You can also use a native callback of the type FOnRemoveChannelGroupResponseNative to handle the result using a lambda.

FOnRemoveChannelGroupResponse

FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.

FOnRemoveChannelGroupResponseNative

FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h



Actor.cpp



Returns

This method doesn't have any return value.

Other Examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Delete a channel group with lambda

You can use a lambda function to handle the response:

Actor.h



Actor.cpp



Delete a channel group with result struct

You can use the result struct to handle the response:

Actor.h



Actor.cpp



Complete example

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

ASample_GroupsFull.h


ASample_GroupsFull.cpp


Last updated on