class Ably::Models::ChannelOptions
Represents options of a channel
Constants
- MODES
-
Describes the possible flags used to configure client capabilities, using {Ably::Models::ChannelOptions::MODES}.
PRESENCE The client can enter the presence set. PUBLISH The client can publish messages. SUBSCRIBE The client can subscribe to messages. PRESENCE_SUBSCRIBE The client can receive presence messages.
@spec TB2d
Attributes
Public Class Methods
Source
# File lib/ably/models/channel_options.rb, line 52 def initialize(attrs) @attributes = IdiomaticRubyWrapper(attrs.clone) attributes[:modes] = modes.to_a.map { |mode| Ably::Models::ChannelOptions::MODES[mode] } if modes attributes[:cipher] = Ably::Models::CipherParams(cipher) if cipher attributes.clone end
Initialize a new ChannelOptions
@spec TB3
@option params [Hash] (TB2c) params (for realtime client libraries only) a of key/value pairs @option modes [Hash] modes (for realtime client libraries only) an array of ChannelMode @option cipher [Hash,Ably::Models::CipherParams] :cipher A hash of options or a {Ably::Models::CipherParams} to configure the encryption. :key is required, all other options are optional.
Public Instance Methods
Source
# File lib/ably/models/channel_options.rb, line 67 def cipher attributes[:cipher] end
Requests encryption for this channel when not null, and specifies encryption-related parameters (such as algorithm, chaining mode, key length and key). See an example.
@spec RSL5a, TB2b
@return [CipherParams]
Source
# File lib/ably/models/channel_options.rb, line 87 def modes attributes[:modes] end
An array of {Ably:Models:ChannelOptions::MODES} objects.
@spec TB2d
@return [Array<ChannelOptions::MODES>]
Source
# File lib/ably/models/channel_options.rb, line 95 def modes_to_flags modes.map { |mode| Ably::Models::ProtocolMessage::ATTACH_FLAGS_MAPPING[mode.to_sym] }.reduce(:|) end
Converts modes to a bitfield that coresponds to ProtocolMessage#flags
@return [Integer]
Source
# File lib/ably/models/channel_options.rb, line 77 def params attributes[:params].to_h end
Channel Parameters that configure the behavior of the channel.
@spec TB2c
@return [Hash]
Source
# File lib/ably/models/channel_options.rb, line 109 def set_modes_from_flags(flags) return unless flags message_modes = MODES.select do |mode| flag = Ably::Models::ProtocolMessage::ATTACH_FLAGS_MAPPING[mode.to_sym] flags & flag == flag end attributes[:modes] = message_modes.map { |mode| Ably::Models::ChannelOptions::MODES[mode] } end
Sets modes from ProtocolMessage#flags
@return [Array<ChannelOptions::MODES>] @api private
Source
# File lib/ably/models/channel_options.rb, line 101 def set_params(hash) attributes[:params] = hash end
@return [Hash] @api private