Channel Groups API for PubNub Vue SDK
Channel groups allow PubNub developers to bundle thousands of channels into a group that can be identified by a name. These channel groups can then be subscribed to, receiving data from the many back-end channels the channel group contains.
Channel group operations
You can't publish to a channel group. You can only subscribe to it. To publish within the channel group, you need to publish to each channel individually.
Add 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 Vue SDK:
Note
200 channels
can be added to the channel group
per API call.
pubnub.channelGroups.addChannels({Array channels, String channelGroup},Function callback)
Parameter | Type | Required | Description |
---|---|---|---|
Operation Arguments | Hash | Yes | A hash of arguments. |
channels | Array | Yes | The channel to add to the channel group. |
channelGroup | String | Yes | The channelGroup to add the channels to. |
callback | Function | Optional | Executes on a successful/unsuccessful addChannels . |
Basic Usage
Add Channels
import PubNubVue from 'pubnub-vue';
const pubnub = PubNubVue.getInstance();
pubnub.channelGroups.addChannels(
{
channels: ['ch1', 'ch2'],
channelGroup: "myChannelGroup"
},
function(status) {
if (status.error) {
console.log("operation failed w/ status: ", status);
} else {
console.log("operation done!");
}
show all 17 linesResponse
{
error: false,
operation: "PNAddChannelsToGroupOperation",
statusCode: 200
}
List 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.
This function lists all the channels of the channel group.
Method(s)
Listing Channels
is accomplished by using the following method(s) in the Vue SDK:
pubnub.channelGroups.listChannels({String channelGroup},Function callback)
Parameter | Type | Required | Description |
---|---|---|---|
Operation Arguments | Hash | Yes | A hash of arguments. |
channelGroup | String | Yes | Channel Group to list the channel(s) of. |
callback | Function | Optional | Executes on a successful/unsuccessful listChannels . |
Basic Usage
List Channels
import PubNubVue from 'pubnub-vue';
const pubnub = PubNubVue.getInstance();
// assuming an intialized PubNub instance already exists
pubnub.channelGroups.listChannels(
{
channelGroup: "myChannelGroup"
},
function(status, response) {
if (status.error) {
console.log("operation failed w/ error:", status);
return;
}
show all 21 linesResponse
// Example of Status
{
error: false,
operation: "PNChannelsForGroupOperation",
statusCode: 200
}
// Example of Response
{
channels: ["ch1", "ch2"]
}
Remove 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.
This function removes the channels from the channel group.
Method(s)
Removing Channels
is accomplished by using the following method(s) in the Vue SDK:
pubnub.channelGroups.removeChannels({Array channels, String channelGroup},Function callback)
Parameter | Type | Required | Description |
---|---|---|---|
Operation Arguments | Hash | Yes | A hash of arguments. |
channels | Array | Yes | The channel to remove from the channel group. |
channelGroup | String | Yes | The channelGroup to remove the channels from. |
callback | Function | Optional | Executes on a successful/unsuccessful removeChannels . |
Basic Usage
Remove channels
import PubNubVue from 'pubnub-vue';
const pubnub = PubNubVue.getInstance();
// assuming an initialized PubNub instance already exists
pubnub.channelGroups.removeChannels(
{
channels: ['son'],
channelGroup: "family"
},
function(status) {
if (status.error) {
console.log("operation failed w/ error:", status);
} else {
console.log("operation done!");
show all 18 linesResponse
{
error: false,
operation: "PNRemoveChannelsFromGroupOperation",
statusCode: 200
}
Delete 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 Vue SDK:
pubnub.channelGroups.deleteGroup({String channelGroup},Function callback)
Parameter | Type | Required | Description |
---|---|---|---|
Operation Arguments | Hash | Yes | A hash of arguments. |
channelGroup | String | Yes | The channelGroup to remove. |
callback | Function | Optional | Executes on a successful/unsuccessful deleteGroup . |
Basic Usage
Delete Channel Group
import PubNubVue from 'pubnub-vue';
const pubnub = PubNubVue.getInstance();
pubnub.channelGroups.deleteGroup(
{
channelGroup: "family"
},
function(status) {
if (status.error) {
console.log("operation failed w/ error:", status);
} else {
console.log("operation done!");
}
}
show all 16 linesResponse
{
error: false,
operation: "PNRemoveGroupOperation",
statusCode: 200
}