RubyRuby V4 Channel Groups API Reference for Realtime Apps

Go to Access Manager


 

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

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

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 Ruby V4 SDK:
 

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

  1. ParameterTypeRequiredDescription
    actionSymbolYesAction that you want to preform, to add, it's :add.
    channelsString, SymbolYesThe channels to add to channel groups.
    channel_groupsString, SymbolYesThe channel_groups to add channels to.
    http_syncBooleanOptional

    Default false. Method will be executed asynchronously and will return future, to get it's value you can use value method. If set to true, method will return array of envelopes (even if there's only one envelope).

    For sync methods Envelope object will be returned.

    callbackLambda accepting one parameterOptional

    Callback that will be called for each envelope.

    For async methods future will be returned, to retrieve value Envelope object you have to call value method (thread will be locked until the value is returned).

# Async without callback
future = pubnub.channel_registration(action: :add, channel: 'my_channel', channel_group: :somegroup)

# Sync without callback
envelopes = pubnub.channel_registration(action: :add, channel: 'my_channel', channel_group: :somegroup, http_sync: true)

# Async with callback (callback can be specified also as :callback key)
future = pubnub.channel_registration(action: :add, channel: 'my_channel', channel_group: :somegroup) { 
	|envelope| puts envelope.status
}
#<Pubnub::Envelope:0x007fd385096220
	@status = {
		:code => 200,
		:category => :ack,
		:error => false,
	}
>
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 Ruby V4 SDK:
  1. ParameterTypeRequiredDescription
    actionSymbolYesTo get all channels from a channel groups you need to specify action as :get.
    channel_groupsString, SymbolYesChannel groups to fetch the channels of.
    http_syncBooleanOptional

    Default false. Method will be executed asynchronously and will return future, to get it's value you can use value method. If set to true, method will return array of envelopes (even if there's only one envelope).

    For sync methods Envelope object will be returned.

    callbackLambda accepting one parameterOptional

    Callback that will be called for each envelope.

    For async methods future will be returned, to retrieve value Envelope object you have to call value method (thread will be locked until the value is returned).

pubnub.channel_registration(action: :get, group: 'family') do |envelope|
	pp envelope
end
#<Pubnub::Envelope:0x007fd385856cf8
	@result = {
		:data => {
			"channels" => ["ben"], 
			"group" => "family"
		}
	}
	@status = {
		:code => 200
	}
>
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 Ruby V4 SDK:
  1. ParameterTypeRequiredDescription
    actionSymbolYesUse :remove to remove channels.
    channelsString, SymbolYesSpecify channels name to remove from channel groups.
    channel_groupsString, SymbolYesSpecify channel_groups name to remove channels from.
    http_syncBooleanOptional

    Default false. Method will be executed asynchronously and will return future, to get it's value you can use value method. If set to true, method will return array of envelopes (even if there's only one envelope).

    For sync methods Envelope object will be returned.

    callbackLambda accepting one parameterOptional

    Callback that will be called for each envelope.

    For async methods future will be returned, to retrieve value Envelope object you have to call value method (thread will be locked until the value is returned).

pubnub.channel_registration(action: :remove, channel: 'son', group: 'family') do |envelope|
	pp envelope
end
#<Pubnub::Envelope:0x007fd385096220
	@status = {
		:code => 200,
		:category => :ack,
		:error => false,
	}
>
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 Ruby V4 SDK:
  1. ParameterTypeRequiredDescription
    actionSymbolYesUse :remove to remove the channel groups.
    channel_groupsString, SymbolYesSpecify channel groups name to remove.
    http_syncBooleanOptional

    Default false. Method will be executed asynchronously and will return future, to get it's value you can use value method. If set to true, method will return array of envelopes (even if there's only one envelope).

    For sync methods Envelope object will be returned.

    callbackLambda accepting one parameterOptional

    Callback that will be called for each envelope.

    For async methods future will be returned, to retrieve value Envelope object you have to call value method (thread will be locked until the value is returned).

pubnub.channel_registration(action: :remove, channel_group: 'family') do |envelope|
    pp envelope
end
#<Pubnub::Envelope:0x007fd385096220
	@status = {
		:code => 200,
		:category => :ack,
		:error => false,
	}
>

Go to Storage and Playback