Class: Ably::Models::ConnectionDetails

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

Overview

Contains any constraints a client should adhere to and provides additional metadata about a Realtime::Connection, such as if a request to Realtime::Client#publish a message that exceeds the maximum message size should be rejected immediately without communicating with Ably.

Constant Summary collapse

MAX_MESSAGE_SIZE =

Max message size

65536
MAX_FRAME_SIZE =

Max frame size

524288

Instance Attribute Summary

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 token. If clientId is null or omitted, then the client is prohibited from assuming a clientId in any operations, however if clientId is a wildcard string *, then the client is permitted to assume any clientId. Any other string value for clientId implies that the clientId is both enforced and assumed for all operations from this client.

  • :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 @HEARTBEAT@ 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



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ably/models/connection_details.rb', line 39

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[:max_message_size] ||= MAX_MESSAGE_SIZE
  self.attributes[:max_frame_size] ||= MAX_FRAME_SIZE
  self.attributes.freeze
end

Instance Method Details

#attributesHash

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



145
146
147
# File 'lib/ably/models/connection_details.rb', line 145

def attributes
  @hash_object
end

#client_idString

Contains the client ID assigned to the token. If clientId is null or omitted, then the client is prohibited from assuming a clientId in any operations, however if clientId is a wildcard string *, then the client is permitted to assume any clientId. Any other string value for clientId implies that the clientId is both enforced and assumed for all operations from this client.

Returns:

  • (String)


60
61
62
# File 'lib/ably/models/connection_details.rb', line 60

def client_id
  attributes[:client_id]
end

#connection_keyString

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

Returns:

  • (String)


70
71
72
# File 'lib/ably/models/connection_details.rb', line 70

def connection_key
  attributes[:connection_key]
end

#connection_state_ttlInteger

The duration that Ably will persist the connection state for when a Realtime client is abruptly disconnected.

Returns:

  • (Integer)


80
81
82
# File 'lib/ably/models/connection_details.rb', line 80

def connection_state_ttl
  attributes[:connection_state_ttl]
end

#has_client_id?Boolean

Returns:

  • (Boolean)


139
140
141
# File 'lib/ably/models/connection_details.rb', line 139

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

#max_frame_sizeInteger

Overrides the default maxFrameSize.

Returns:

  • (Integer)


90
91
92
# File 'lib/ably/models/connection_details.rb', line 90

def max_frame_size
  attributes[:max_frame_size]
end

#max_idle_intervalInteger

The maximum length of time in milliseconds that the server will allow no activity to occur in the server to client direction. After such a period of inactivity, the server will send a HEARTBEAT or transport-level ping to the client. If the value is 0, the server will allow arbitrarily-long levels of inactivity.

Returns:

  • (Integer)


135
136
137
# File 'lib/ably/models/connection_details.rb', line 135

def max_idle_interval
  attributes[:max_idle_interval]
end

#max_inbound_rateInteger

The maximum allowable number of requests per second from a client or Ably. In the case of a realtime connection, this restriction applies to the number of messages sent, whereas in the case of REST, it is the total number of REST requests per second.

Returns:

  • (Integer)


101
102
103
# File 'lib/ably/models/connection_details.rb', line 101

def max_inbound_rate
  attributes[:max_inbound_rate]
end

#max_message_sizeInteger

The maximum message size is an attribute of an Ably account and enforced by Ably servers. maxMessageSize indicates the maximum message size allowed by the Ably account this connection is using. Overrides the default value of ClientOptions.maxMessageSize.

Returns:

  • (Integer)


113
114
115
# File 'lib/ably/models/connection_details.rb', line 113

def max_message_size
  attributes[:max_message_size]
end

#server_idString

A unique identifier for the front-end server that the client has connected to. This server ID is only used for the purposes of debugging.

Returns:

  • (String)


123
124
125
# File 'lib/ably/models/connection_details.rb', line 123

def server_id
  attributes[:server_id]
end