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.
Adding Channels
Requires Stream Controller add-on Requires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-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:
Note
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 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 typePNChannelGroupsAddChannelResult
.
Basic Usage
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 Requires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-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 typePNChannelGroupsAllChannelsResult
.
Basic Usage
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 | List of channels of a channel group . |
Removing Channels
Requires Stream Controller add-on Requires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-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 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 typePNChannelGroupsRemoveChannelResult
.
Basic Usage
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 Requires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:
https://support.pubnub.com/hc/en-us/articles/360051974791-How-do-I-enable-add-on-features-for-my-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 typePNChannelGroupsDeleteGroupResult
.
Basic Usage
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()
.