Class: Ably::Models::ConnectionDetails

Inherits:
Object
  • Object
show all
Includes:
Ably::Modules::ModelCommon
Defined in:
lib/ably/models/connection_details.rb

Overview

ConnectionDetails are optionally passed to the client library in the CONNECTED ProtocolMessage#connectionDetails attribute to inform the client about any constraints it should adhere to and provide additional metadata about the connection. For example, if a request is made to publish a message that exceeds the maxMessageSize, the client library can reject the message immediately, without communicating with the Ably service

Instance Attribute Summary collapse

Attributes included from Ably::Modules::ModelCommon

#hash

Instance Method Summary collapse

Methods included from Ably::Modules::ModelCommon

#==, #[], #as_json, included, #to_json, #to_s

Methods included from Ably::Modules::MessagePack

#to_msgpack

Constructor Details

#initialize(attributes = {}) ⇒ ConnectionDetails

Returns a new instance of ConnectionDetails

Parameters:

  • attributes (Hash) (defaults to: {})

Options Hash (attributes):

  • :client_id (String)

    contains the client ID assigned to the connection

  • :connection_key (String)

    the connection secret key string that is used to resume a connection and its state

  • :max_message_size (Integer)

    maximum individual message size in bytes

  • :max_frame_size (Integer)

    maximum size for a single frame of data sent to Ably. This restriction applies to a ProtocolMessage sent over a realtime connection, or the total body size for a REST request

  • :max_inbound_rate (Integer)

    maximum allowable number of requests per second from a client

  • :max_idle_interval (Integer)

    is the maximum length of time in seconds that the server will allow no activity to occur in the server->client direction. After such a period of inactivity, the server will send a @[email protected] or transport-level ping to the client. If the value is 0, the server will allow arbitrarily-long levels of inactivity.

  • :connection_state_ttl (Integer)

    duration in seconds that Ably will persist the connection state when a Realtime client is abruptly disconnected

  • :server_id (String)

    unique identifier of the Ably server where the connection is established


34
35
36
37
38
39
40
41
42
# File 'lib/ably/models/connection_details.rb', line 34

def initialize(attributes = {})
  @hash_object = IdiomaticRubyWrapper(attributes.clone)
  [:connection_state_ttl, :max_idle_interval].each do |duration_field|
    if self.attributes[duration_field]
      self.attributes[duration_field] = (self.attributes[duration_field].to_f / 1000).round
    end
  end
  self.attributes.freeze
end

Instance Attribute Details

#attributesHash (readonly)

Returns Access the token details Hash object ruby'fied to use symbolized keys

Returns:

  • (Hash)

    Access the token details Hash object ruby'fied to use symbolized keys


56
57
58
# File 'lib/ably/models/connection_details.rb', line 56

def attributes
  @hash_object
end

Instance Method Details

#has_client_id?Boolean

Returns:

  • (Boolean)

50
51
52
# File 'lib/ably/models/connection_details.rb', line 50

def has_client_id?
  attributes.has_key?(:client_id)
end