lib/submodules/ably-ruby/lib/ably/realtime/client.rb in ably-rest-0.9.3 vs lib/submodules/ably-ruby/lib/ably/realtime/client.rb in ably-rest-1.0.0

- old
+ new

@@ -76,12 +76,14 @@ # @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 + # @option options [Integer] :channel_retry_timeout (15 seconds). When a channel becomes SUSPENDED, after this delay in seconds, the channel will automatically attempt to reattach if the connection is CONNECTED + # @option options [Integer] :disconnected_retry_timeout (15 seconds). When the connection enters the DISCONNECTED state, after this delay in seconds, 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 seconds, if the state is still SUSPENDED, the client library will attempt to reconnect automatically + # @option options [Boolean] :disable_websocket_heartbeats WebSocket heartbeats are more efficient than protocol level heartbeats, however they can be disabled for development purposes # # @return [Ably::Realtime::Client] # # @example # # create a new client authenticating with basic auth @@ -89,10 +91,21 @@ # # # create a new client and configure a client ID used for presence # client = Ably::Realtime::Client.new(key: 'key.id:secret', client_id: 'john') # def initialize(options) - @rest_client = Ably::Rest::Client.new(options) + raise ArgumentError, 'Options Hash is expected' if options.nil? + + options = options.clone + if options.kind_of?(String) + options = if options.match(Ably::Auth::API_KEY_REGEX) + { key: options } + else + { token: options } + end + end + + @rest_client = Ably::Rest::Client.new(options.merge(realtime_client: self)) @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