Channel Groups API for PubNub Unity SDK
Channel Groups allows PubNub developers to bundle thousands of channels into a group that can be identified by name. These Channel Groups can then be subscribed to, receiving data from the many backend-channels the channel group contains.
Learn more about our Channel Groups here.
Channel Group operations
You can't publish to a Channel Group. You can only subscribe to it. To publish within Channel Group, you need to publish to each channel individually.
Adding 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.
Description
This function adds a channel to a channel group.
Method(s)
Adding Channels
is accomplished by using the following method(s) in the Unity V4 SDK:
Maximum number of channels
200 channels
can be added to the channel group
per API call.
pubnub.AddChannelsToChannelGroup().Channels(List<string>).ChannelGroup(string).QueryParam(Dictionary<string,string>).Async()
Parameter | Type | Required | Description |
---|---|---|---|
Channels | List<string> | Yes | The Channels to add to the channel group. |
ChannelGroup | string | Yes | The ChannelGroup to add the channels to. |
QueryParam | Dictionary<string, string> | Optional | QueryParam accepts a Dictionary object, the keys and values are passed as the query string parameters of the URL called by the API. |
Async | PNCallback | Yes | PNCallback of type PNChannelGroupsAddChannelResult . |
Basic Usage
**Adding Channels
pubnub.AddChannelsToChannelGroup()
.Channels(new List<string> (){"my_channel"})
.ChannelGroup("channelGroup")
.Async((result, status) => {
if(status.Error){
Debug.Log (string.Format("In Example, AddChannelsToChannelGroup Error: {0} {1} {2}", status.StatusCode, status.ErrorData, status.Category));
} else {
Debug.Log (string.Format("DateTime {0}, In Example AddChannelsToChannelGroup, result: {1}", DateTime.UtcNow, result.Message));
}
});
Returns
The AddChannelsToChannelGroup()
does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.isError()
.
Listing 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.
Description
This function lists all the channels of the channel group.
Method(s)
Listing Channels
is accomplished by using the following method(s) in the Unity V4 SDK:
pubnub.ListChannelsForChannelGroup().ChannelGroup(string).QueryParam(Dictionary<string,string>).Async()
Parameter | Type | Required | Description |
---|---|---|---|
ChannelGroup | string | Yes | Channel group to fetch the channels. |
QueryParam | Dictionary<string, string> | Optional | QueryParam accepts a Dictionary object, the keys and values are passed as the query string parameters of the URL called by the API. |
Async | PNCallback | Yes | PNCallback of type PNChannelGroupsAllChannelsResult . |
Basic Usage
Listing Channels
pubnub.ListChannelsForChannelGroup()
.ChannelGroup("cg")
.Async((result, status) => {
if(status.Error){
Debug.Log (string.Format("In Example, ListAllChannelsOfGroup Error: {0} {1} {2}", status.StatusCode, status.ErrorData, status.Category));
} else {
Debug.Log (string.Format("In Example ListAllChannelsOfGroup, result: {0}", (result.Channels!=null)?string.Join(",", result.Channels.ToArray()):""));
}
});
Returns
The ListChannelsForChannelGroup()
operation returns a PNChannelGroupsAllChannelsResult
which contains the following operations:
Method | Type | Description |
---|---|---|
Channels | List<string> | List of channels of a channel group . |
Removing 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.
Description
This function removes the channels from the channel group.
Method(s)
Removing Channels
is accomplished by using the following method(s) in the Unity V4 SDK:
pubnub.RemoveChannelsFromChannelGroup().Channels(new List<string>).ChannelGroup(string).QueryParam(Dictionary<string,string>).Async()
Parameter | Type | Required | Description |
---|---|---|---|
Channels | List<string> | Yes | The Channels to remove from the channel group. |
ChannelGroup | string | Yes | Specifies ChannelGroup to remove the channels from. |
QueryParam | Dictionary<string, string> | Optional | QueryParam accepts a Dictionary object, the keys and values are passed as the query string parameters of the URL called by the API. |
Async | PNCallback | Optional | PNCallback of type PNChannelGroupsRemoveChannelResult . |
Basic Usage
Removing channels
pubnub.RemoveChannelsFromChannelGroup()
.Channels(new List<string> (){"son"})
.ChannelGroup("family")
.Async((result, status) => {
Debug.Log ("in RemoveChannelsFromCG");
if(status.Error){
Debug.Log (string.Format("In Example, RemoveChannelsFromCG Error: {0} {1} {2}", status.StatusCode, status.ErrorData, status.Category));
} else {
Debug.Log (string.Format("DateTime {0}, In RemoveChannelsFromCG, result: {1}", DateTime.UtcNow, result.Message));
}
});
Returns
The RemoveChannelsFromChannelGroup()
does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.IsError()
.
Deleting 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.
Description
This function removes the channel group.
Method(s)
Deleting Channel Group
is accomplished by using the following method(s) in the Unity V4 SDK:
pubnub.DeleteChannelGroup().ChannelGroup(string).QueryParam(Dictionary<string,string>).Async()
Parameter | Type | Required | Description |
---|---|---|---|
ChannelGroup | string | Yes | Specifies ChannelGroup to remove. |
QueryParam | Dictionary<string, string> | Optional | QueryParam accepts a Dictionary object, the keys and values are passed as the query string parameters of the URL called by the API. |
Async | PNCallback | Optional | PNCallback of type PNChannelGroupsDeleteGroupResult . |
Basic Usage
Deleting Channel Group
pubnub.DeleteChannelGroup()
.ChannelGroup("family")
.Async((result1, status1) => {
if(status1.Error){
Debug.Log (string.Format("In Example, DeleteChannelsFromChannelGroup Error: {0} {1} {2}", status1.StatusCode, status1.ErrorData, status1.Category));
} else {
Debug.Log (string.Format("DateTime {0}, In Example DeleteChannelsFromChannelGroup, result: {1}", DateTime.UtcNow, result1.Message));
}
});
Response
The DeleteChannelGroup()
does not return actionable data, be sure to check the status object on the outcome of the operation by checking the status.IsError()
.