lib/submodules/ably-ruby/lib/ably/realtime/client.rb in ably-rest-0.8.5 vs lib/submodules/ably-ruby/lib/ably/realtime/client.rb in ably-rest-0.8.6

- old
+ new

@@ -28,10 +28,14 @@ attr_reader :channels # (see Ably::Rest::Client#auth) attr_reader :auth + # The underlying connection for this client + # @return [Aby::Realtime::Connection] + attr_reader :connection + # The {Ably::Rest::Client REST client} instantiated with the same credentials and configuration that is used for all REST operations such as authentication # @return [Ably::Rest::Client] attr_reader :rest_client # When false the client suppresses messages originating from this connection being echoed back on the same connection. Defaults to true @@ -67,10 +71,13 @@ # @option options [Boolean] :queue_messages If false, this disables the default behaviour whereby the library queues messages on a connection in the disconnected or connecting states # @option options [Boolean] :echo_messages If false, prevents messages originating from this connection being echoed back on the same connection # @option options [String] :recover When a recover option is specified a connection inherits the state of a previous connection that may have existed under a different instance of the Realtime library, please refer to the API documentation for further information on connection state recovery # @option options [Boolean] :auto_connect By default as soon as the client library is instantiated it will connect to Ably. You can optionally set this to false and explicitly connect. # + # @option options [Integer] :disconnected_retry_timeout (15 seconds). When the connection enters the DISCONNECTED state, after this delay in milliseconds, if the state is still DISCONNECTED, the client library will attempt to reconnect automatically + # @option options [Integer] :suspended_retry_timeout (30 seconds). When the connection enters the SUSPENDED state, after this delay in milliseconds, if the state is still SUSPENDED, the client library will attempt to reconnect automatically + # # @return [Ably::Realtime::Client] # # @example # # create a new client authenticating with basic auth # client = Ably::Realtime::Client.new('key.id:secret') @@ -80,10 +87,11 @@ # def initialize(options) @rest_client = Ably::Rest::Client.new(options) @auth = Ably::Realtime::Auth.new(self) @channels = Ably::Realtime::Channels.new(self) + @connection = Ably::Realtime::Connection.new(self, options) @echo_messages = @rest_client.options.fetch(:echo_messages, true) == false ? false : true @queue_messages = @rest_client.options.fetch(:queue_messages, true) == false ? false : true @custom_realtime_host = @rest_client.options[:realtime_host] || @rest_client.options[:ws_host] @auto_connect = @rest_client.options.fetch(:auto_connect, true) == false ? false : true @recover = @rest_client.options[:recover] @@ -140,13 +148,12 @@ # @return [URI::Generic] Default Ably Realtime endpoint used for all requests def endpoint endpoint_for_host(custom_realtime_host || [environment, DOMAIN].compact.join('-')) end - # @!attribute [r] connection - # @return [Aby::Realtime::Connection] The underlying connection for this client + def connection - @connection ||= Connection.new(self) + @connection end # (see Ably::Rest::Client#register_encoder) def register_encoder(encoder) rest_client.register_encoder encoder