Channel Groups API for Unity 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 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.
Method(s)
Use the following method in the Unity SDK:
Maximum number of channels
You can add up to 200 channels to a channel group per API call.
1pubnub.AddChannelsToChannelGroup()
2 .ChannelGroup(string)
3 .Channels(Array)
4 .QueryParam(Dictionary<string,object>)
5 .Execute(System.Action<PNChannelGroupsAddChannelResult, PNStatus>);
| Parameter | Description |
|---|---|
ChannelGroup *Type: string | The ChannelGroup to add the channels to. |
Channels *Type: Array | The Channels to add to the channel group. |
QueryParamType: Dictionary <string, object> | Name-value pairs to include as query parameters. |
AsyncType: | PNCallback of type PNChannelGroupsAddChannelResult. |
Execute *Type: System.Action | System.Action of type PNChannelGroupsAddChannelResult. |
ExecuteAsyncType: None | Returns Task<PNResult<PNChannelGroupsAddChannelResult>>. |
Sample code
Add channels
Reference code
1
Returns
The AddChannelsToChannelGroup() operation returns a PNResult<PNChannelGroupsAddChannelResult> with:
| Property Name | Type | Description |
|---|---|---|
Result | PNChannelGroupsAddChannelResult | The operation result. |
Status | PNStatus | The request status. |
PNChannelGroupsAddChannelResult includes:
| Property Name | Type | Description |
|---|---|---|
PNChannelGroupsAddChannelResult | Object | Empty object. |
PNStatus | Object | Request status, including errors. |
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 a channel group.
Method(s)
Use the following method in the Unity SDK:
1pubnub.ListChannelsForChannelGroup()
2 .ChannelGroup(string)
3 .QueryParam(Dictionary<string,object>)
4 .Execute(System.Action<PNChannelGroupsAllChannelsResult, PNStatus>);
| Parameter | Description |
|---|---|
ChannelGroup *Type: string | The channel group to fetch the channels of. |
QueryParamType: Dictionary <string, object> | Name-value pairs to include as query parameters. |
AsyncType: | PNCallback of type PNChannelGroupsAllChannelsResult. |
Execute *Type: System.Action | System.Action of type PNChannelGroupsAllChannelsResult. |
ExecuteAsyncType: None | Returns Task<PNResult<PNChannelGroupsAllChannelsResult>>. |
Sample code
List channels
1
Returns
The ListChannelsForChannelGroup() operation returns a PNChannelGroupsAllChannelsResult with:
| Property Name | Type | Description |
|---|---|---|
Result | PNChannelGroupsAllChannelsResult | The operation result. |
Status | PNStatus | The request status. |
PNChannelGroupsAllChannelsResult includes:
| Property Name | Type | Description |
|---|---|---|
Channels | List<string> | Channel names in the group. |
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 a channel group.
Method(s)
Use the following method in the Unity SDK:
1pubnub.RemoveChannelsFromChannelGroup()
2 .ChannelGroup(string)
3 .Channels(Array)
4 .QueryParam(Dictionary<string,object>)
5 .Execute((result, status) => {});
| Parameter | Description |
|---|---|
ChannelGroup *Type: string | The channel group to remove channels from. |
Channels *Type: Array | The channels to remove. |
QueryParamType: Dictionary <string, object> | Name-value pairs to include as query parameters. |
AsyncType: | PNCallback of type PNChannelGroupsRemoveChannelResult. |
Execute *Type: System.Action | System.Action of type PNChannelGroupsRemoveChannelResult. |
ExecuteAsyncType: None | Returns Task<PNResult<PNChannelGroupsRemoveChannelResult>>. |
Sample code
Remove channels
1
Returns
The RemoveChannelsFromChannelGroup() operation returns a PNChannelGroupsAddChannelResult with:
| Property Name | Type | Description |
|---|---|---|
Result | PNChannelGroupsRemoveChannelResult | The operation result. |
Status | PNStatus | The request status. |
PNChannelGroupsRemoveChannelResult includes:
| Property Name | Type | Description |
|---|---|---|
PNChannelGroupsRemoveChannelResult | Object | Empty object. |
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.
Method(s)
Use the following method in the Unity SDK:
1pubnub.DeleteChannelGroup()
2 .ChannelGroup(string)
3 .QueryParam(Dictionary<string,object>)
4 .Execute(System.Action<PNChannelGroupsDeleteGroupResult, PNStatus>);
| Parameter | Description |
|---|---|
ChannelGroup *Type: string | The channel group to remove. |
QueryParamType: Dictionary <string, object> | Name-value pairs to include as query parameters. |
AsyncType: | PNCallback of type PNChannelGroupsDeleteGroupResult. |
Execute *Type: System.Action | System.Action of type PNChannelGroupsDeleteGroupResult. |
ExecuteAsyncType: None | Returns Task<PNResult<PNChannelGroupsDeleteGroupResult>>. |
Sample code
Delete channel group
1
Returns
The DeleteChannelGroup() operation returns a PNResult<PNChannelGroupsDeleteGroupResult> with:
| Property Name | Type | Description |
|---|---|---|
Status | int | HTTP status code. |
Error | bool | True if the operation failed. |
1{
2 "status" : 200,
3 "message" : "OK",
4 "service" : "channel-registry",
5 "error" : False
6}