PubNub LogoDocs
SupportContact SalesLoginTry Our APIs

›API Reference

c-Sharp

  • Getting Started
  • API Reference

    • Configuration
    • Publish & Subscribe
    • Presence
    • Access Manager
    • Channel Groups
    • Message Persistence
    • Mobile Push
    • Objects
    • Files
    • Message Actions
    • Miscellaneous
  • Status Events
  • Troubleshooting
  • Change Log
  • Feature Support
  • Platform Support

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.

Adding Channels

Requires Stream Controller add-onRequires 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 C# V4 SDK:

Note

200 channels can be added to the channel group per API call.

  1. pubnub.AddChannelsToChannelGroup().ChannelGroup(string).Channels(Array).QueryParam(Dictionary<string,object>)
    
    ParameterTypeRequiredDescription
    ChannelGroupstringYesThe ChannelGroup to add the channels to.
    ChannelsArrayYesThe Channels to add to the channel group.
    QueryParamDictionary<string, object>OptionalDictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose.
    AsyncPNCallbackDeprecatedPNCallback of type PNChannelGroupsAddChannelResult.
    ExecutePNCallbackYesPNCallback of type PNChannelGroupsAddChannelResult.
    ExecuteAsyncNoneOptionalReturns 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 NameTypeDescription
ResultPNChannelGroupsAddChannelResultReturns a PNChannelGroupsAddChannelResult object.
StatusPNStatusReturns a PNStatus object.

PNChannelGroupsAddChannelResult contains the following properties:

Property NameTypeDescription
PNChannelGroupsAddChannelResultObjectReturns empty object.
PNStatusObjectReturns status of request if error occurred or not.

Listing Channels

Requires Stream Controller add-onRequires 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 C# V4 SDK:

  1. pubnub.ListChannelsForChannelGroup().ChannelGroup(string).QueryParam(Dictionary<string,object>)
    
    ParameterTypeRequiredDescription
    ChannelGroupstringYesChannel group to fetch the channels.
    QueryParamDictionary<string, object>OptionalDictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose.
    AsyncPNCallbackDeprecatedPNCallback of type PNChannelGroupsAllChannelsResult.
    ExecutePNCallbackYesPNCallback of type PNChannelGroupsAllChannelsResult.
    ExecuteAsyncNoneOptionalReturns 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 NameTypeDescription
ResultPNChannelGroupsAllChannelsResultReturns a PNChannelGroupsAllChannelsResult object.
StatusPNStatusReturns a PNStatus object.

PNChannelGroupsAllChannelsResult contains the following property:

Property NameTypeDescription
ChannelsListList of channels of a channel group.

Removing Channels

Requires Stream Controller add-onRequires 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 C# V4 SDK:

  1. pubnub.RemoveChannelsFromChannelGroup().ChannelGroup(string).Channels(Array).QueryParam(Dictionary<string,object>)
    
    ParameterTypeRequiredDescription
    ChannelGroupstringYesSpecifies ChannelGroup to remove the channels from.
    ChannelsArrayYesThe Channels to remove from the channel group.
    QueryParamDictionary<string, object>OptionalDictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose.
    AsyncPNCallbackDeprecatedPNCallback of type PNChannelGroupsRemoveChannelResult.
    ExecutePNCallbackYesPNCallback of type PNChannelGroupsRemoveChannelResult.
    ExecuteAsyncNoneOptionalReturns 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 NameTypeDescription
ResultPNChannelGroupsRemoveChannelResultReturns a PNChannelGroupsRemoveChannelResult object.
StatusPNStatusReturns a PNStatus object.

PNChannelGroupsRemoveChannelResult contains the following property:

Property NameTypeDescription
PNChannelGroupsRemoveChannelResultObjectReturns empty object.

Deleting Channel Group

Requires Stream Controller add-onRequires 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 C# V4 SDK:

  1. pubnub.DeleteChannelGroup().ChannelGroup(string).QueryParam(Dictionary<string,object>)
    
    ParameterTypeRequiredDescription
    ChannelGroupstringYesSpecifies ChannelGroup to remove.
    QueryParamDictionary<string, object>OptionalDictionary object to pass name/value pairs as query string params with PubNub URL request for debug purpose.
    AsyncPNCallbackDeprecatedPNCallback of type PNChannelGroupsDeleteGroupResult.
    ExecutePNCallbackYesPNCallback of type PNChannelGroupsDeleteGroupResult.
    ExecuteAsyncNoneOptionalReturns 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
}
← Access ManagerMessage Persistence →
  • Adding Channels
    • Description
    • Method(s)
    • Basic Usage
    • Returns
  • Listing Channels
    • Description
    • Method(s)
    • Basic Usage
    • Returns
  • Removing Channels
    • Description
    • Method(s)
    • Basic Usage
    • Returns
  • Deleting Channel Group
    • Description
    • Method(s)
    • Basic Usage
    • Response
© PubNub Inc. - Privacy Policy