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. See Enable the features your app calls.

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 = PubnubClient->CreateChannelGroupEntity("my-channel-group");
2
3ChannelGroupEntity->AddChannelToGroupAsync(
4 FString Channel,
5 FOnPubnubAddChannelToGroupResponse OnAddChannelToGroupResponse
6);
required
Channel required#
Type: FString
The channel to add to the channel group.
OnAddChannelToGroupResponse required#
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​

Actor.h​

1

Actor.cpp​

1

Returns​

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

Other Examples​

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
Channel required#
Type: FString
The channel to add to the channel group.
ChannelGroup required#
Type: FString
The channel group to add the channels to.
OnAddChannelToGroupResponse required#
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​

Actor.h​

1

Actor.cpp​

1

Returns​

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

FOnPubnubAddChannelToGroupResponse​

Delegate type: DECLARE_DYNAMIC_DELEGATE_OneParam

Result#
The operation result.
FOnPubnubAddChannelToGroupResponseNative​

Native callback variant that accepts a lambda.

Result#
The operation result.

Other Examples​

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. See Enable the features your app calls.

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 = PubnubClient->CreateChannelGroupEntity("my-channel-group");
2
3ChannelGroupEntity->ListChannelsFromGroupAsync(
4 FOnPubnubListChannelsFromGroupResponse OnListChannelsResponse
5);
required
OnListChannelsResponse required#
The operation result delegate. You can also use FOnPubnubListChannelsFromGroupResponseNative with a lambda.

Sample code​

Actor.h​

1

Actor.cpp​

1

Returns​

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

Other Examples​

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
ChannelGroup required#
Type: FString
The channel group to list channels of.
OnListChannelsResponse required#
The operation result delegate. You can also use FOnPubnubListChannelsFromGroupResponseNative with a lambda.

Sample 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

Result#
The operation result.
Channels#
Type: const TArray<FString>&
Channel names in the group.
FOnPubnubListChannelsFromGroupResponseNative​

Native callback variant that accepts a lambda.

Result#
The operation result.
Channels#
Type: const TArray<FString>&
Channel names in the group.

Other Examples​

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. See Enable the features your app calls.

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 = PubnubClient->CreateChannelGroupEntity("my-channel-group");
2
3ChannelGroupEntity->RemoveChannelFromGroupAsync(
4 FString Channel,
5 FOnPubnubRemoveChannelFromGroupResponse OnRemoveChannelFromGroupResponse
6);
required
Channel required#
Type: FString
The channel to remove from the channel group.
OnRemoveChannelFromGroupResponse required#
The operation result delegate. You can also use FOnPubnubRemoveChannelFromGroupResponseNative with a lambda.

Sample code​

Actor.h​

1

Actor.cpp​

1

Returns​

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

Other Examples​

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
Channel required#
Type: FString
The channel to remove from the channel group.
ChannelGroup required#
Type: FString
The channel group to remove the channel from.
OnRemoveChannelFromGroupResponse required#
The operation result delegate. You can also use FOnPubnubRemoveChannelFromGroupResponseNative with a lambda.

Sample 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

Result#
The operation result.
FOnPubnubRemoveChannelFromGroupResponseNative​

Native callback variant that accepts a lambda.

Result#
The operation result.

Other Examples​

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. See Enable the features your app calls.

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 = PubnubClient->CreateChannelGroupEntity("my-channel-group");
2
3ChannelGroupEntity->RemoveChannelGroupAsync(
4 FOnPubnubRemoveChannelGroupResponse OnRemoveChannelGroupResponse
5);
required
OnRemoveChannelGroupResponse required#
The operation result delegate. You can also use FOnPubnubRemoveChannelGroupResponseNative with a lambda.

Sample code​

Actor.h​

1

Actor.cpp​

1

Returns​

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

Other Examples​

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
ChannelGroup required#
Type: FString
The channel group to remove.
OnRemoveChannelGroupResponse required#
The operation result delegate. You can also use FOnPubnubRemoveChannelGroupResponseNative with a lambda.

Sample 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

Result#
The operation result.
FOnPubnubRemoveChannelGroupResponseNative​

Native callback variant that accepts a lambda.

Result#
The operation result.

Other Examples​

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​

ASample_GroupsFull.h​

1

ASample_GroupsFull.cpp​

1

Was this page useful?

Last updated on