GoGo V4 Channel Groups API Reference for Realtime Apps

 

These docs are for PubNub 4.0 for Go which is our latest and greatest! For the docs of the older versions of the SDK, please check PubNub 3.0 for Go.

If you have questions about the PubNub for Go 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 Go V4 SDK:
 

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

  1. ParameterTypeRequiredDescription
    Channels[]stringYeschannels to add to the channel group
    ChannelGroupstringYesThe channel group to add the channels to.
    QueryParammap[string]stringOptionalQueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API.
pn.AddChannelToChannelGroup().
    Channels([]string{"ch1", "ch2"}).
    ChannelGroup("cg").
    Execute()
{
    "service" : "channel-registry",
    "status"  : 200,
    "error"   : false,
    "message" : "OK"
}

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 Go V4 SDK:
  1. ParameterTypeRequiredDescription
    ChannelGroupstringYesThe channel group to fetch channels.
    QueryParammap[string]stringOptionalQueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API.
pn.ListChannelsInChannelGroup().
    ChannelGroup("cg").
    Execute()
MethodTypeDescription
Channels[]stringYes
GroupstringYes

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 Go V4 SDK:
  1. ParameterTypeRequiredDescription
    Channels[]stringYeschannels remove from the channel group.
    ChannelGroupstringYesThe channel group to remove the channels from.
    QueryParammap[string]stringOptionalQueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API.
pn.RemoveChannelFromChannelGroup().
    ChannelGroup("cg").
    Channels([]string{"ch1", "ch2"}).
    Execute()
{
    Error:<nil>
    Category:Unknown
    Operation:Remove Channel From Channel Group
    StatusCode:200
    TLSEnabled:true
    UUID:d9713e5a-6bcb-439a-942e-5ba064f2e5dd
    AuthKey:
    Origin:ps.pndsn.com
    OriginalResponse: {
        "status": 200,
        "message": "OK",
        "service": "channel-registry",
        "error": false
    }
    AffectedChannels:[]
    AffectedChannelGroups:[]
}

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 Go V4 SDK:
  1. ParameterTypeRequiredDescription
    ChannelGroupstringYesThe channel group to remove
    QueryParammap[string]stringOptionalQueryParam accepts a map, the keys and values of the map are passed as the query string parameters of the URL called by the API.
pn.DeleteChannelGroup().
    ChannelGroup("remove-cg").
    Execute()
{
    Error:<nil>
    Category:Unknown
    Operation:Remove Channel Group
    StatusCode:200
    TLSEnabled:true
    UUID:650089a0-922c-4de6-b422-7a38a964bf45
    AuthKey:
    Origin:ps.pndsn.com
    OriginalResponse: {
        "status": 200,
        "message": "OK",
        "service": "channel-registry",
        "error": false
    }
    AffectedChannels:[]
    AffectedChannelGroups:[]
}