Channel Groups API for PubNub C# 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 C# V4 SDK:
Maximum number of channels
200 channels
can be added to the channel group
per API call.
pubnub.AddChannelsToChannelGroup().ChannelGroup(string).Channels(Array).QueryParam(Dictionary<string,object>)
Parameter | Type | Required | Description |
---|---|---|---|
ChannelGroup | string | Yes | The ChannelGroup to add the channels to. |
Channels | Array | Yes | The Channels to add to the channel group. |
QueryParam | Dictionary<string, object> | Optional | Dictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose. |
Async | PNCallback | Deprecated | PNCallback of type PNChannelGroupsAddChannelResult . |
Execute | PNCallback | Yes | PNCallback of type PNChannelGroupsAddChannelResult . |
ExecuteAsync | None | Optional | Returns PNResult<PNChannelGroupsAddChannelResult> . |
Basic Usage
Adding Channels
PNResult<PNChannelGroupsAddChannelResult> cgAddChResponse = await pubnub.AddChannelsToChannelGroup()
.ChannelGroup("cg1")
.Channels(new string[] {
"ch1",
"ch2",
"ch3"
})
.ExecuteAsync();
Returns
The AddChannelsToChannelGroup()
operation returns a PNResult<PNChannelGroupsAddChannelResult>
which contains the following properties:
Property Name | Type | Description |
---|---|---|
Result | PNChannelGroupsAddChannelResult | Returns a PNChannelGroupsAddChannelResult object. |
Status | PNStatus | Returns a PNStatus object. |
PNChannelGroupsAddChannelResult
contains the following properties:
Property Name | Type | Description |
---|---|---|
PNChannelGroupsAddChannelResult | Object | Returns empty object. |
PNStatus | Object | Returns status of request if error occurred or not. |
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 C# V4 SDK:
pubnub.ListChannelsForChannelGroup().ChannelGroup(string).QueryParam(Dictionary<string,object>)
Parameter | Type | Required | Description |
---|---|---|---|
ChannelGroup | string | Yes | Channel group to fetch the channels. |
QueryParam | Dictionary<string, object> | Optional | Dictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose. |
Async | PNCallback | Deprecated | PNCallback of type PNChannelGroupsAllChannelsResult . |
Execute | PNCallback | Yes | PNCallback of type PNChannelGroupsAllChannelsResult . |
ExecuteAsync | None | Optional | Returns PNResult<PNChannelGroupsAllChannelsResult> . |
Basic Usage
Listing Channels
PNResult<PNChannelGroupsAllChannelsResult> cgListChResponse = await pubnub.ListChannelsForChannelGroup()
.ChannelGroup("cg1")
.ExecuteAsync();
Returns
The ListChannelsForChannelGroup()
operation returns a PNChannelGroupsAllChannelsResult
which contains the following properties:
Property Name | Type | Description |
---|---|---|
Result | PNChannelGroupsAllChannelsResult | Returns a PNChannelGroupsAllChannelsResult object. |
Status | PNStatus | Returns a PNStatus object. |
PNChannelGroupsAllChannelsResult
contains the following property:
Property Name | 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 C# V4 SDK:
pubnub.RemoveChannelsFromChannelGroup().ChannelGroup(string).Channels(Array).QueryParam(Dictionary<string,object>)
Parameter | Type | Required | Description |
---|---|---|---|
ChannelGroup | string | Yes | Specifies ChannelGroup to remove the channels from. |
Channels | Array | Yes | The Channels to remove from the channel group. |
QueryParam | Dictionary<string, object> | Optional | Dictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose. |
Async | PNCallback | Deprecated | PNCallback of type PNChannelGroupsRemoveChannelResult . |
Execute | PNCallback | Yes | PNCallback of type PNChannelGroupsRemoveChannelResult . |
ExecuteAsync | None | Optional | Returns PNResult<PNChannelGroupsRemoveChannelResult> . |
Basic Usage
Removing channels
PNResult<PNChannelGroupsRemoveChannelResult> rmChFromCgResponse = await pubnub.RemoveChannelsFromChannelGroup()
.ChannelGroup("family")
.Channels(new string[] {
"son"
})
.ExecuteAsync();
Returns
The RemoveChannelsFromChannelGroup()
operation returns a PNChannelGroupsAddChannelResult
which contains the following properties:
Property Name | Type | Description |
---|---|---|
Result | PNChannelGroupsRemoveChannelResult | Returns a PNChannelGroupsRemoveChannelResult object. |
Status | PNStatus | Returns a PNStatus object. |
PNChannelGroupsRemoveChannelResult
contains the following property:
Property Name | Type | Description |
---|---|---|
PNChannelGroupsRemoveChannelResult | Object | Returns empty object. |
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 C# V4 SDK:
pubnub.DeleteChannelGroup().ChannelGroup(string).QueryParam(Dictionary<string,object>)
Parameter | Type | Required | Description |
---|---|---|---|
ChannelGroup | string | Yes | Specifies ChannelGroup to remove. |
QueryParam | Dictionary<string, object> | Optional | Dictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose. |
Async | PNCallback | Deprecated | PNCallback of type PNChannelGroupsDeleteGroupResult . |
Execute | PNCallback | Yes | PNCallback of type PNChannelGroupsDeleteGroupResult . |
ExecuteAsync | None | Optional | Returns PNResult<PNChannelGroupsAllChannelsResult> . |
Basic Usage
Deleting Channel Group
PNResult<PNChannelGroupsDeleteGroupResult> delCgResponse = await pubnub.DeleteChannelGroup()
.ChannelGroup("family")
.ExecuteAsync();
Response
{
"status" : 200,
"message" : "OK",
"service" : "channel-registry",
"error" : False
}