Channel Groups API for PubNub Python-Twisted SDK
Deprecated
NOTICE: Based on current web trends and our own usage data, PubNub's Python Twisted SDK is deprecated as of May 1, 2019. Deprecation means we will no longer be updating the Python Twisted SDK but will continue to support users currently using it. Please feel free to use our other Python SDK offerings as they will continue to be supported and maintained. If you would like to use the Python Twisted SDK specifically, we would love to work with you on keeping this project alive!
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 Python-Twisted SDK:
Note
200 channels
can be added to the channel group
per API call.
pubnub.add_channel_to_channel_group().channels(String|List|Tuple).channel_group(String)
Parameter | Type | Required | Description |
---|---|---|---|
channels | String | List | Tuple | Yes | The channel to add to the channel_group . |
channel_group | String | Yes | The channel_group to add the channels to. |
Basic Usage
Adding Channels
d = pubnub.add_channel_to_channel_group().\
channels(["ch1", "ch2"]).\
channel_group("cg1").\
deferred()
d.addCallback(my_callback)
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 Python-Twisted SDK:
pubnub.list_channels_in_channel_group().channel_group(String)
Parameter | Type | Required | Description |
---|---|---|---|
channel_group | String | Yes | The channel group to fetch channels. |
Basic Usage
Listing Channels
envelope = yield pubnub.list_channels_in_channel_group().\
channel_group("cg1").future()
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 Python-Twisted SDK:
pubnub.remove_channel_from_channel_group().channels(String|List|Tuple).channel_group(String)
Parameter | Type | Required | Description |
---|---|---|---|
channels | String | List | Tuple | Yes | The channels to remove from the channel group. |
channel_group | String | Yes | Specifies channel_group to remove the channels from. |
Basic Usage
Removing channels
# if we're using inlineCallbacks
envelope = yield pubnub.remove_channel_from_channel_group()\
.group(channel_group)\
.channels(["son", "daughter"])\
.deferred()
# if we're not using inlineCallbacks
d = pubnub.remove_channel_from_channel_group()\
.group(channel_group)\
.channels(["son", "daughter"])\
.deferred()
d.addCallback(my_callback)
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 (with Enable Wildcard Subscribe checked). 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 Python-Twisted SDK:
pubnub.remove_channel_group().channel_group(String)
Parameter | Type | Required | Description |
---|---|---|---|
channel_group | String | Yes | The channel group to remove. |
Basic Usage
Deleting Channel Group
# if we're using inlineCallbacks
envelope = yield pubnub.remove_channel_group()\
.group(channel_group)\
.deferred()
# if we're not using inlineCallbacks
d = pubnub.remove_channel_group()\
.group(channel_group)\
.deferred()
d.addCallback(my_callback)