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

- old
+ new

@@ -88,17 +88,17 @@ 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] + @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] - raise ArgumentError, "Recovery key is invalid" if @recover && !@recover.match(Connection::RECOVER_REGEX) + raise ArgumentError, "Recovery key '#{recover}' is invalid" if recover && !recover.match(Connection::RECOVER_REGEX) end # Return a {Ably::Realtime::Channel Realtime Channel} for the given name # # @param (see Ably::Realtime::Channels#get) @@ -148,15 +148,10 @@ # @return [URI::Generic] Default Ably Realtime endpoint used for all requests def endpoint endpoint_for_host(custom_realtime_host || [environment, DOMAIN].compact.join('-')) end - - def connection - @connection - end - # (see Ably::Rest::Client#register_encoder) def register_encoder(encoder) rest_client.register_encoder encoder end @@ -174,10 +169,10 @@ # @!attribute [r] fallback_endpoint # @return [URI::Generic] Fallback endpoint used to connect to the realtime Ably service. Note, after each connection attempt, a new random {Ably::FALLBACK_HOSTS fallback host} is used # @api private def fallback_endpoint - unless @fallback_endpoints + unless defined?(@fallback_endpoints) && @fallback_endpoints @fallback_endpoints = Ably::FALLBACK_HOSTS.shuffle.map { |fallback_host| endpoint_for_host(fallback_host) } end fallback_endpoint_index = connection.manager.retry_count_for_state(:disconnected) + connection.manager.retry_count_for_state(:suspended)