lib/submodules/ably-ruby/lib/ably/realtime/connection.rb in ably-rest-0.8.9 vs lib/submodules/ably-ruby/lib/ably/realtime/connection.rb in ably-rest-0.8.13

- old
+ new

@@ -192,19 +192,19 @@ end end # Sends a ping to Ably and yields the provided block when a heartbeat ping request is echoed from the server. # This can be useful for measuring true roundtrip client to Ably server latency for a simple message, or checking that an underlying transport is responding currently. - # The elapsed milliseconds is passed as an argument to the block and represents the time taken to echo a ping heartbeat once the connection is in the `:connected` state. + # The elapsed time in seconds is passed as an argument to the block and represents the time taken to echo a ping heartbeat once the connection is in the `:connected` state. # - # @yield [Integer] if a block is passed to this method, then this block will be called once the ping heartbeat is received with the time elapsed in milliseconds. + # @yield [Integer] if a block is passed to this method, then this block will be called once the ping heartbeat is received with the time elapsed in seconds. # If the ping is not received within an acceptable timeframe, the block will be called with +nil+ as he first argument # # @example # client = Ably::Rest::Client.new(key: 'key.id:secret') - # client.connection.ping do |ms_elapsed| - # puts "Ping took #{ms_elapsed}ms" + # client.connection.ping do |elapsed_s| + # puts "Ping took #{elapsed_s}s" # end # # @return [void] # def ping(&block) @@ -217,11 +217,11 @@ wait_for_ping = Proc.new do |protocol_message| next if finished if protocol_message.action == Ably::Models::ProtocolMessage::ACTION.Heartbeat finished = true __incoming_protocol_msgbus__.unsubscribe(:protocol_message, &wait_for_ping) - time_passed = (Time.now.to_f * 1000 - started.to_f * 1000).to_i + time_passed = Time.now.to_f - started.to_f safe_yield block, time_passed if block_given? end end once_or_if(STATE.Connected) do @@ -385,10 +385,12 @@ # Getting auth params can be blocking so uses a Deferrable client.auth.auth_params.tap do |auth_deferrable| auth_deferrable.callback do |auth_params| url_params = auth_params.merge( format: client.protocol, - echo: client.echo_messages + echo: client.echo_messages, + v: Ably::PROTOCOL_VERSION, + lib: Ably::LIB_VERSION_ID, ) url_params['clientId'] = client.auth.client_id if client.auth.has_client_id? if connection_resumable?