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++


Asynchronous and synchronous method execution

Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.

  • Asynchronous methods (Async suffix) return void and take an optional delegate parameter that fires when the operation completes.

    1PubnubClient->AddChannelToGroupAsync("my-channel", "my-group", OnAddChannelToGroupResponseDelegate);

    You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the Native suffix (for example, FOnPubnubAddChannelToGroupResponseNative).

  • Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.

    1FPubnubOperationResult Result = PubnubClient->AddChannelToGroup("my-channel", "my-group");

Add channels to a channel group​

Requires Stream Controller add-on

This method requires the Stream Controller add-on enabled for your key in the Admin Portal. Read the support page on enabling add-on features.

This function adds a channel to a channel group. You can call AddChannelToGroup() on a ChannelGroup entity (which already knows its channel group) or directly on the PubNub client by passing the channel group name explicitly.

Maximum number of channels

You can add up to 200 channels to a channel group per API call.

ChannelGroup entity​

icon

Available in entities

ChannelGroup

Method(s)​

1UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubSubsystem->CreateChannelGroupEntity("my-channel-group");
2
3ChannelGroupEntity->AddChannelToGroup(
4 FString Channel,
5 FOnAddChannelToGroupResponse OnAddChannelToGroupResponse
6);
* required
ParameterDescription
Channel *
Type: FString
The channel to add to the channel group.
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
ResultFPubnubOperationResultThe operation result.
FOnAddChannelToGroupResponseNative​
FieldTypeDescription
Resultconst FPubnubOperationResult&The operation result.

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​

1

Actor.cpp​

1

Returns​

This method is void, but the delegate returns the FOnAddChannelToGroupResponse struct.

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​

Use a lambda function to handle the response:

Actor.h​
1

Actor.cpp​
1

Add channels to a channel group with result struct​

Use the result struct to handle the response:

Actor.h​

1

Actor.cpp​

1

PubNub client​

Method(s)​

1PubnubClient->AddChannelToGroupAsync(
2 FString Channel,
3 FString ChannelGroup,
4 FOnPubnubAddChannelToGroupResponse OnAddChannelToGroupResponse
5);
* 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 FOnPubnubAddChannelToGroupResponseNative to handle the result using a lambda.

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​

1

Actor.cpp​

1

Returns​

This method is void. The delegate returns the following struct:

FOnPubnubAddChannelToGroupResponse​

Delegate type: DECLARE_DYNAMIC_DELEGATE_OneParam

ParameterDescription
ResultThe operation result.
FOnPubnubAddChannelToGroupResponseNative​

Native callback variant that accepts a lambda.

ParameterDescription
ResultThe operation result.

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​

Use a lambda function to handle the response:

Actor.h​

1

Actor.cpp​

1

Add channels to a channel group with result struct​

Use the result struct to handle the response:

Actor.h​

1

Actor.cpp​

1

List channels in a channel group​

Requires Stream Controller add-on

This method requires the Stream Controller add-on enabled for your key in the Admin Portal. Read the support page on enabling add-on features.

This function lists all channels in the channel group. You can call ListChannelsFromGroup() on a ChannelGroup entity (which already knows its channel group) or directly on the PubNub client by passing the channel group name explicitly.

ChannelGroup entity​

icon

Available in entities

ChannelGroup

Method(s)​

1UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubSubsystem->CreateChannelGroupEntity("my-channel-group");
2
3ChannelGroupEntity->ListChannelsFromGroup(
4 FOnListChannelsFromGroupResponse OnListChannelsResponse
5);
* required
ParameterDescription
OnListChannelsResponse *The operation result delegate. You can also use FOnListChannelsFromGroupResponseNative with a lambda.
FOnListChannelsFromGroupResponse​
FieldTypeDescription
ResultFPubnubOperationResultThe operation result.
ChannelsTArray<FString>&Channel names in the group.
FOnListChannelsFromGroupResponseNative​
FieldTypeDescription
Resultconst FPubnubOperationResult&The operation result.
Channelsconst TArray<FString>&Channel names in the 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​

1

Actor.cpp​

1

Returns​

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

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​

Use a lambda function to handle the response:

Actor.h​
1

Actor.cpp​
1

List channels from a channel group with result struct​

Use the result struct to handle the response:

Actor.h​

1

Actor.cpp​

1

PubNub client​

Method(s)​

1PubnubClient->ListChannelsFromGroupAsync(
2 FString ChannelGroup,
3 FOnPubnubListChannelsFromGroupResponse OnListChannelsResponse
4);
* required
ParameterDescription
ChannelGroup *
Type: FString
The channel group to list channels of.
OnListChannelsResponse *The operation result delegate. You can also use FOnPubnubListChannelsFromGroupResponseNative with a lambda.

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​

1

Actor.cpp​

1

Returns​

This method is void. The delegate returns the following struct:

FOnPubnubListChannelsFromGroupResponse​

Delegate type: DECLARE_DYNAMIC_DELEGATE_TwoParams

ParameterDescription
ResultThe operation result.
Channels
Type: const TArray<FString>&
Channel names in the group.
FOnPubnubListChannelsFromGroupResponseNative​

Native callback variant that accepts a lambda.

ParameterDescription
ResultThe operation result.
Channels
Type: const TArray<FString>&
Channel names in the 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​

Use a lambda function to handle the response:

Actor.h​

1

Actor.cpp​

1

Remove channels from a channel group​

Requires Stream Controller add-on

This method requires the Stream Controller add-on enabled for your key in the Admin Portal. Read the support page on enabling add-on features.

This function removes channels from the channel group. You can call RemoveChannelFromGroup() on a ChannelGroup entity (which already knows its channel group) or directly on the PubNub client by passing the channel group name explicitly.

ChannelGroup entity​

icon

Available in entities

ChannelGroup

Method(s)​

1UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubSubsystem->CreateChannelGroupEntity("my-channel-group");
2
3ChannelGroupEntity->RemoveChannelFromGroup(
4 FString Channel,
5 FOnRemoveChannelFromGroupResponse OnRemoveChannelFromGroupResponse
6);
* required
ParameterDescription
Channel *
Type: FString
The channel to remove from the channel group.
OnRemoveChannelFromGroupResponse *The operation result delegate. You can also use FOnRemoveChannelFromGroupResponseNative with a lambda.
FOnRemoveChannelFromGroupResponse​
FieldTypeDescription
ResultFPubnubOperationResultThe operation result.
FOnRemoveChannelFromGroupResponseNative​
FieldTypeDescription
Resultconst FPubnubOperationResult&The operation result.

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​

1

Actor.cpp​

1

Returns​

This method is void, but the delegate returns the FOnRemoveChannelFromGroupResponse struct.

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​

Use a lambda function to handle the response:

Actor.h​
1

Actor.cpp​
1

Remove channels from a channel group with result struct​

Use the result struct to handle the response:

Actor.h​

1

Actor.cpp​

1

PubNub client​

Method(s)​

1PubnubClient->RemoveChannelFromGroupAsync(
2 FString Channel,
3 FString ChannelGroup,
4 FOnPubnubRemoveChannelFromGroupResponse OnRemoveChannelFromGroupResponse
5);
* required
ParameterDescription
Channel *
Type: FString
The channel to remove from the channel group.
ChannelGroup *
Type: FString
The channel group to remove the channel from.
OnRemoveChannelFromGroupResponse *The operation result delegate. You can also use FOnPubnubRemoveChannelFromGroupResponseNative with a lambda.

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​

1

Actor.cpp​

1

Returns​

This method is void. The delegate returns the following struct:

FOnPubnubRemoveChannelFromGroupResponse​

Delegate type: DECLARE_DYNAMIC_DELEGATE_OneParam

ParameterDescription
ResultThe operation result.
FOnPubnubRemoveChannelFromGroupResponseNative​

Native callback variant that accepts a lambda.

ParameterDescription
ResultThe operation result.

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​

Use a lambda function to handle the response:

Actor.h​

1

Actor.cpp​

1

Remove channels from a channel group with result struct​

Use the result struct to handle the response:

Actor.h​

1

Actor.cpp​

1

Delete a channel group​

Requires Stream Controller add-on

This method requires the Stream Controller add-on enabled for your key in the Admin Portal. Read the support page on enabling add-on features.

This function removes a channel group. You can call RemoveChannelGroup() on a ChannelGroup entity (which already knows its channel group) or directly on the PubNub client by passing the channel group name explicitly.

ChannelGroup entity​

icon

Available in entities

ChannelGroup

Method(s)​

1UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubSubsystem->CreateChannelGroupEntity("my-channel-group");
2
3ChannelGroupEntity->RemoveChannelGroup(
4 FOnRemoveChannelGroupResponse OnRemoveChannelGroupResponse
5);
* required
ParameterDescription
OnRemoveChannelGroupResponse *The operation result delegate. You can also use FOnRemoveChannelGroupResponseNative with a lambda.
FOnRemoveChannelGroupResponse​
FieldTypeDescription
ResultFPubnubOperationResultThe operation result.
FOnRemoveChannelGroupResponseNative​
FieldTypeDescription
Resultconst FPubnubOperationResult&The operation result.

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​

1

Actor.cpp​

1

Returns​

This method is void, but the delegate returns the FOnRemoveChannelGroupResponse struct.

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​

Use a lambda function to handle the response:

Actor.h​
1

Actor.cpp​
1

Delete a channel group with result struct​

Use the result struct to handle the response:

Actor.h​

1

Actor.cpp​

1

PubNub client​

Method(s)​

1PubnubClient->RemoveChannelGroupAsync(
2 FString ChannelGroup,
3 FOnPubnubRemoveChannelGroupResponse OnRemoveChannelGroupResponse
4);
* required
ParameterDescription
ChannelGroup *
Type: FString
The channel group to remove.
OnRemoveChannelGroupResponse *The operation result delegate. You can also use FOnPubnubRemoveChannelGroupResponseNative with a lambda.

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​

1

Actor.cpp​

1

Returns​

This method is void. The delegate returns the following struct:

FOnPubnubRemoveChannelGroupResponse​

Delegate type: DECLARE_DYNAMIC_DELEGATE_OneParam

ParameterDescription
ResultThe operation result.
FOnPubnubRemoveChannelGroupResponseNative​

Native callback variant that accepts a lambda.

ParameterDescription
ResultThe operation result.

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​

Use a lambda function to handle the response:

Actor.h​

1

Actor.cpp​

1

Delete a channel group with result struct​

Use the result struct to handle the response:

Actor.h​

1

Actor.cpp​

1

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​

1

ASample_GroupsFull.cpp​

1

Deprecated methods​

Add channels to a channel group (deprecated)​

Deprecated

Method(s) (deprecated)​

1PubnubSubsystem->AddChannelToGroup(
2 FString Channel,
3 FString ChannelGroup,
4 FOnAddChannelToGroupResponse OnAddChannelToGroupResponse
5);
* 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 *
Type: FOnAddChannelToGroupResponse
The delegate for the operation's result.

Returns (deprecated)​

This method doesn't return a value.

List channels in a channel group (deprecated)​

Deprecated

Method(s) (deprecated)​

1PubnubSubsystem->ListChannelsFromGroup(
2 FString ChannelGroup,
3 FOnListChannelsFromGroupResponse OnListChannelsResponse
4);
* required
ParameterDescription
ChannelGroup *
Type: FString
The channel group to list channels of.
OnListChannelsResponse *
Type: FOnListChannelsFromGroupResponse
The operation result delegate.

Returns (deprecated)​

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

FieldTypeDescription
ResultFPubnubOperationResultThe operation result.
ChannelsTArray<FString>&Channel names in the group.

Remove channels from a channel group (deprecated)​

Deprecated

Method(s) (deprecated)​

1PubnubSubsystem->RemoveChannelFromGroup(
2 FString Channel,
3 FString ChannelGroup,
4 FOnRemoveChannelFromGroupResponse OnRemoveChannelFromGroupResponse
5);
* required
ParameterDescription
Channel *
Type: FString
The channel to remove from the channel group.
ChannelGroup *
Type: FString
The channel group to remove the channel from.
OnRemoveChannelFromGroupResponse *
Type: FOnRemoveChannelFromGroupResponse
The operation result delegate.

Returns (deprecated)​

This method doesn't return a value.

Delete a channel group (deprecated)​

Deprecated

Method(s) (deprecated)​

1PubnubSubsystem->RemoveChannelGroup(
2 FString ChannelGroup,
3 FOnRemoveChannelGroupResponse OnRemoveChannelGroupResponse
4);
* required
ParameterDescription
ChannelGroup *
Type: FString
The channel group to remove.
OnRemoveChannelGroupResponse *
Type: FOnRemoveChannelGroupResponse
The operation result delegate.

Returns (deprecated)​

This method doesn't return a value.

Was this page useful?

Last updated on