C#C# V4 Channel Groups API Reference for Realtime Apps

 

These docs are for PubNub 4.0 for C# which is our latest and greatest! For the docs of the 3.x versions of the SDK, please check the links: C#, Windows 8, Windows 8.1, ASP.Net, Windows Phone 8, Windows Phone 8.1, Xamarin.iOS, Xamarin.Android, Xamarin.Mac and C# PCL.

If you have questions about the PubNub for C# SDK, please contact us at support@pubnub.com.

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


Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function adds a channel to a channel group.
Adding Channels is accomplished by using the following method(s) in the C# V4 SDK:
 

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

  1. 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.
pubnub.AddChannelsToChannelGroup()
    .ChannelGroup("cg1")
    .Channels(new string[] { 
        "ch1", 
        "ch2", 
        "ch3"
    })
    .Execute(new PNChannelGroupsAddChannelResultExt(
        (result, status) => {                     
        }
    ));
The AddChannelsToChannelGroup() operation returns a result which contains the following property:
Property NameTypeDescription
PNChannelGroupsAddChannelResultObjectReturns empty object.
PNStatusObjectReturns status of request if error occured or not.

Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function lists all the channels of the channel group.
Listing Channels is accomplished by using the following method(s) in the C# V4 SDK:
  1. 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.
pubnub.ListChannelsForChannelGroup()
    .ChannelGroup("cg1")
    .Execute(new PNChannelGroupsAllChannelsResultExt(
        (result, status) => {
        }
    ));
The ListChannelsForChannelGroup() operation returns a PNChannelGroupsAllChannelsResult which contains the following property:
Property NameTypeDescription
ChannelsList<string>List of channels of a channel group.

Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function removes the channels from the channel group.
Removing Channels is accomplished by using the following method(s) in the C# V4 SDK:
  1. 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.
pubnub.RemoveChannelsFromChannelGroup()
    .ChannelGroup("family")
    .Channels(new string[] {
        "son"
    })
    .Execute(new PNChannelGroupsRemoveChannelResultExt(
        (result, status) => {
        }
    ));
The RemoveChannelsFromChannelGroup() operation returns a result which contains the following property:
Property NameTypeDescription
PNChannelGroupsAddChannelResultObjectReturns empty object.
PNStatusObjectReturns status of request if error occured or not.

Requires Stream Controller add-on XRequires that the Stream Controller add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.
This function removes the channel group.
Deleting Channel Group is accomplished by using the following method(s) in the C# V4 SDK:
  1. 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.
pubnub.DeleteChannelGroup()
    .ChannelGroup("family")
    .Execute(new PNChannelGroupsDeleteGroupResultExt(
        (result, status) => {
        }
    ));

{
	"status" : 200,
	"message" : "OK",
	"service" : "channel-registry",
	"error" : False
}