PubNub LogoDocs
SupportContact SalesLoginTry Our APIs

›API Reference

posix-C

  • Getting Started
  • API Reference

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

Channel Groups API for PubNub POSIX 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-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 Posix C SDK:

  1. enum pubnub_res pubnub_add_channel_to_group (pubnub_t *p, char const *channel, char const *channel_group)
    
    ParameterTypeRequiredDescription
    ppubnub_t*YesPointer to PubNub client context.
    channelchar const*YesThe channel to add
    channel_groupchar const*YesThe channel group to add to

Basic Usage

Adding Channels :

static char *channel_group = "family";
enum pubnub_res res;
res = pubnub_add_channel_to_group(pn, "wife", channel_group);
return check_response(pn, res);

Rest Response from Server

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

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 Posix C SDK:

  1. enum pubnub_res pubnub_list_channel_group (pubnub_t *p, char const *channel_group)
    
    ParameterTypeRequiredDescription
    ppubnub_t*YesPointer to PubNub client context.
    channel_groupchar const*YesThe channel group to list channels from

Basic Usage

Listing Channels :

static char *channel_group = "family";
pubnub_list_channel_group(ctx, channel_group);
pbresult = pubnub_await(ctx);
if (PNR_OK == pbresult) {
    char const *json_response = pubnub_get(ctx);
}

Rest Response from Server

{
    "status" : 200,
    "payload" : {
        "channels" : ["hi"],
        "group" : "abcd"
    },
    "service" : "channel-registry",
    "error" : False
}

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 Posix C SDK:

  1. enum pubnub_res pubnub_remove_channel_from_group (pubnub_t *p, char const *channel, char const *channel_group)
    
    ParameterTypeRequiredDescription
    ppubnub_t*YesPointer to PubNub client context.
    channelchar const*YesThe channel to remove
    channel_groupchar const*YesThe channel group to remove from

Basic Usage

Removing channels :

static char *channel_group = "family";
enum pubnub_res res;
res = pubnub_remove_channel_from_group(pn, "son", channel_group);
return check_response(pn, res);

Rest Response from Server

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

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 Posix C SDK:

  1. enum pubnub_res pubnub_remove_channel_group (pubnub_t *p, char const *channel_group)
    
    ParameterTypeRequiredDescription
    ppubnub_t*YesPointer to PubNub client context.
    channel_groupchar const*YesThe channel group to remove.

Basic Usage

Deleting Channel Group :

static char *channel_group = "family";
enum pubnub_res res;
res = pubnub_remove_channel_group(pn, channel_group);
return check_response(pn, res);

Rest Response from Server

{
    "status" : 200,
    "message" : "OK",
    "service" : "channel-registry",
    "error" : False
}
← Access ManagerMessage Persistence →
  • Adding Channels
    • Description
    • Method(s)
    • Basic Usage
    • Rest Response from Server
  • Listing Channels
    • Description
    • Method(s)
    • Basic Usage
    • Rest Response from Server
  • Removing Channels
    • Description
    • Method(s)
    • Basic Usage
    • Rest Response from Server
  • Deleting Channel Group
    • Description
    • Method(s)
    • Basic Usage
    • Rest Response from Server
© PubNub Inc. - Privacy Policy