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.
Asynchronous and synchronous method execution
Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.
-
Asynchronous methods (
Asyncsuffix) returnvoidand 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
Nativesuffix (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
Method(s)
1UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubSubsystem->CreateChannelGroupEntity("my-channel-group");
2
3ChannelGroupEntity->AddChannelToGroup(
4 FString Channel,
5 FOnAddChannelToGroupResponse OnAddChannelToGroupResponse
6);
| Parameter | Description |
|---|---|
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
| Field | Type | Description |
|---|---|---|
Result | FPubnubOperationResult | The operation result. |
FOnAddChannelToGroupResponseNative
| Field | Type | Description |
|---|---|---|
Result | const FPubnubOperationResult& | The operation result. |
Sample code
Reference code
ACTION REQUIRED before running the code.Returns
This method is void, but the delegate returns the FOnAddChannelToGroupResponse struct.
Other Examples
Reference code
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);
| Parameter | Description |
|---|---|
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
ACTION REQUIRED before running the code.Returns
This method is void. The delegate returns the following struct:
FOnPubnubAddChannelToGroupResponse
Delegate type: DECLARE_DYNAMIC_DELEGATE_OneParam
| Parameter | Description |
|---|---|
ResultType: FPubnubOperationResult | The operation result. |
FOnPubnubAddChannelToGroupResponseNative
Native callback variant that accepts a lambda.
| Parameter | Description |
|---|---|
Result | The operation result. |
Other Examples
Reference code
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
Method(s)
1UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubSubsystem->CreateChannelGroupEntity("my-channel-group");
2
3ChannelGroupEntity->ListChannelsFromGroup(
4 FOnListChannelsFromGroupResponse OnListChannelsResponse
5);
| Parameter | Description |
|---|---|
OnListChannelsResponse * | The operation result delegate. You can also use FOnListChannelsFromGroupResponseNative with a lambda. |
FOnListChannelsFromGroupResponse
| Field | Type | Description |
|---|---|---|
Result | FPubnubOperationResult | The operation result. |
Channels | TArray<FString>& | Channel names in the group. |
FOnListChannelsFromGroupResponseNative
| Field | Type | Description |
|---|---|---|
Result | const FPubnubOperationResult& | The operation result. |
Channels | const TArray<FString>& | Channel names in the group. |
Sample code
Reference code
ACTION REQUIRED before running the code.Returns
This function is void, but the delegate returns the FOnListChannelsFromGroupResponse struct.
Other Examples
Reference code
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);
| Parameter | Description |
|---|---|
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
ACTION REQUIRED before running the code.Returns
This method is void. The delegate returns the following struct:
FOnPubnubListChannelsFromGroupResponse
Delegate type: DECLARE_DYNAMIC_DELEGATE_TwoParams
| Parameter | Description |
|---|---|
ResultType: FPubnubOperationResult | The operation result. |
ChannelsType: const TArray<FString>& | Channel names in the group. |
FOnPubnubListChannelsFromGroupResponseNative
Native callback variant that accepts a lambda.
| Parameter | Description |
|---|---|
Result | The operation result. |
ChannelsType: const TArray<FString>& | Channel names in the group. |
Other Examples
Reference code
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
Method(s)
1UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubSubsystem->CreateChannelGroupEntity("my-channel-group");
2
3ChannelGroupEntity->RemoveChannelFromGroup(
4 FString Channel,
5 FOnRemoveChannelFromGroupResponse OnRemoveChannelFromGroupResponse
6);
| Parameter | Description |
|---|---|
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
| Field | Type | Description |
|---|---|---|
Result | FPubnubOperationResult | The operation result. |
FOnRemoveChannelFromGroupResponseNative
| Field | Type | Description |
|---|---|---|
Result | const FPubnubOperationResult& | The operation result. |
Sample code
Reference code
ACTION REQUIRED before running the code.Returns
This method is void, but the delegate returns the FOnRemoveChannelFromGroupResponse struct.
Other Examples
Reference code
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);
| Parameter | Description |
|---|---|
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
ACTION REQUIRED before running the code.Returns
This method is void. The delegate returns the following struct:
FOnPubnubRemoveChannelFromGroupResponse
Delegate type: DECLARE_DYNAMIC_DELEGATE_OneParam
| Parameter | Description |
|---|---|
ResultType: FPubnubOperationResult | The operation result. |
FOnPubnubRemoveChannelFromGroupResponseNative
Native callback variant that accepts a lambda.
| Parameter | Description |
|---|---|
Result | The operation result. |
Other Examples
Reference code
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
Method(s)
1UPubnubChannelGroupEntity* ChannelGroupEntity = PubnubSubsystem->CreateChannelGroupEntity("my-channel-group");
2
3ChannelGroupEntity->RemoveChannelGroup(
4 FOnRemoveChannelGroupResponse OnRemoveChannelGroupResponse
5);
| Parameter | Description |
|---|---|
OnRemoveChannelGroupResponse * | The operation result delegate. You can also use FOnRemoveChannelGroupResponseNative with a lambda. |
FOnRemoveChannelGroupResponse
| Field | Type | Description |
|---|---|---|
Result | FPubnubOperationResult | The operation result. |
FOnRemoveChannelGroupResponseNative
| Field | Type | Description |
|---|---|---|
Result | const FPubnubOperationResult& | The operation result. |
Sample code
Reference code
ACTION REQUIRED before running the code.Returns
This method is void, but the delegate returns the FOnRemoveChannelGroupResponse struct.
Other Examples
Reference code
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);
| Parameter | Description |
|---|---|
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
ACTION REQUIRED before running the code.- C++
- Blueprint